Skip to content

Commit

Permalink
update Page form
Browse files Browse the repository at this point in the history
  • Loading branch information
glpzzz committed Jun 22, 2020
1 parent 1e8d262 commit bd1eb9b
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 81 deletions.
70 changes: 39 additions & 31 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
{
"name": "daxslab/yii2-website-module",
"description": "Yii2 module to manage website content. Kind of a CMS...",
"type": "yii2-extension",
"keywords": ["yii2","module","cms","website"],
"license": "MIT",
"authors": [
{
"name": "Gabriel A. López López",
"email": "glpz@daxslab.com"
}
],
"minimum-stability": "stable",
"require": {
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap4": "~2.0.6",
"2amigos/yii2-ckeditor-widget" : "^2.0",
"2amigos/yii2-gallery-widget": "~1.0",
"daxslab/yii2-thumbnailer": "~1.0",
"daxslab/yii2-taggedview": "~1.0",
"daxslab/yii2-uploader-behavior": "~1.0",
"vinpel/yii2-dropzone": "~1.0.4",
"zelenin/yii2-rss": "~0.1.0",
"yii2tech/ar-position": "^1.0"
},
"autoload": {
"psr-4": {
"daxslab\\website\\": ""
}
},
"extra": {
"bootstrap": "daxslab\\website\\Bootstrap"
"name": "daxslab/yii2-website-module",
"description": "Yii2 module to manage website content. Kind of a CMS...",
"type": "yii2-extension",
"keywords": [
"yii2",
"module",
"cms",
"website"
],
"license": "MIT",
"authors": [
{
"name": "Gabriel A. López López",
"email": "glpz@daxslab.com"
}
],
"minimum-stability": "stable",
"require": {
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap4": "~2.0.6",
"2amigos/yii2-ckeditor-widget": "^2.0",
"2amigos/yii2-gallery-widget": "~1.0",
"daxslab/yii2-thumbnailer": "~1.0",
"daxslab/yii2-taggedview": "~1.0",
"daxslab/yii2-uploader-behavior": "~1.0",
"daxslab/yii2-sharelinks-widget": "^1.0",
"yiisoft/yii2-jui": "*",
"vinpel/yii2-dropzone": "~1.0.4",
"zelenin/yii2-rss": "~0.1.0",
"yii2tech/ar-position": "^1.0",
"kartik-v/yii2-widget-switchinput": "^1.3"
},
"autoload": {
"psr-4": {
"daxslab\\website\\": ""
}
},
"extra": {
"bootstrap": "daxslab\\website\\Bootstrap"
}
}
2 changes: 1 addition & 1 deletion models/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function attributeLabels()
'slug' => Yii::t('website','Slug'),
'abstract' => Yii::t('website','Abstract'),
'body' => Yii::t('website','Body'),
'image' => Yii::t('website','Image'),
'image' => Yii::t('website','Page Poster'),
'language' => Yii::t('website','Language'),
];
}
Expand Down
104 changes: 56 additions & 48 deletions views/backend/page/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

<div class="row">
<div class="col-md-8">


<div class="row">
<div class="col-md-8">
<?= $form->field($model, 'title') ?>
Expand Down Expand Up @@ -82,70 +84,76 @@
</div>
<div class="col-md-4">

<div class="image-area">
<div class="form-group">
<?= Html::img(isset($model->image) ? $model->image : $defaultImage, ['id' => 'page-image-preview', 'class' => 'img-fluid']) ?>
<div class="input-group">

<?= Html::activeTextInput($model, 'image', ['class' => 'form-control']) ?>

<div class="btn-group" role="group" aria-label="Basic example">

<?= Html::button(Yii::t('website', 'Set'), [
'class' => 'btn btn-primary',
<?= $form->field($model, 'status')->widget(\kartik\switchinput\SwitchInput::class, [
'pluginOptions' => [
'onText' => Yii::t('website', 'Published'),
'offText' => Yii::t('app', 'Draft'),
],
'options' => [
'onchange' => "this.form.submit()",
]
]) ?>

<div class="card mb-4">
<?= Html::activeLabel($model, 'image', ['class' => 'card-header']) ?>
<?= Html::img(isset($model->image) ? $model->image : $defaultImage, ['id' => 'page-image-preview', 'class' => 'img-fluid']) ?>
<div class="image-area card-body p-0">
<div class="form-group mb-0">
<div class="input-group">
<?= Html::activeTextInput($model, 'image', ['class' => 'form-control']) ?>
<div class="btn-group" role="group" aria-label="Basic example">
<?= Html::button(Yii::t('website', 'Set'), [
'class' => 'btn btn-primary',
'data' => [
'toggle' => 'modal',
'target' => '#image-gallery-modal',
]]) ?>
<?= Html::button(Yii::t('website', 'Delete'), [
'id' => 'btn-remove-picture',
'class' => 'btn btn-danger',
]) ?>
</div>
</div><!-- /input-group -->
<?php
\yii\bootstrap4\Modal::begin([
'id' => 'image-gallery-modal',
'size' => \yii\bootstrap4\Modal::SIZE_LARGE,
'title' => Yii::t('website', 'Select an image'),
'options' => [
'data' => [
'toggle' => 'modal',
'target' => '#image-gallery-modal',
]]) ?>

<?= Html::button(Yii::t('website', 'Delete'), [
'id' => 'btn-remove-picture',
'class' => 'btn btn-danger',
]) ?>

</div>

</div><!-- /input-group -->

<?php
\yii\bootstrap4\Modal::begin([
'id' => 'image-gallery-modal',
'size' => \yii\bootstrap4\Modal::SIZE_LARGE,
'title' => Yii::t('website', 'Select an image'),
'options' => [
'data' => [
'target-field' => '#page-image',
'preview' => '#page-image-preview',
'default-image' => $defaultImage,
'target-field' => '#page-image',
'preview' => '#page-image-preview',
'default-image' => $defaultImage,
]
]
]
])
?>

<?= Yii::$app->runAction("/$module/media/images-gallery") ?>

<?php \yii\bootstrap4\Modal::end() ?>
])
?>
<?= Yii::$app->runAction("/$module/media/images-gallery") ?>
<?php \yii\bootstrap4\Modal::end() ?>
</div>
</div>
</div>

<?= $form->field($model, 'status')->dropDownList(Lookup::getPostStatusOptions()) ?>

<?php foreach ($metadatas as $index => $md): ?>
<?php if ($md->metadataDefinition->type == \yii\validators\BooleanValidator::class): ?>
<?= $form->field($md, "[{$index}]value")->checkbox()->label($md->metadataDefinition->name) ?>
<?= $form->field($md, "[{
$index
}]value")->checkbox()->label($md->metadataDefinition->name) ?>
<?php else: ?>
<?= $form->field($md, "[{$index}]value")->label($md->metadataDefinition->name) ?>
<?= $form->field($md, "[{
$index
}]value")->label($md->metadataDefinition->name) ?>
<?php endif; ?>
<?php endforeach; ?>

<div class="form-group">
<div class="form-group border-top pt-3">
<?= Html::submitButton(Yii::t('website', 'Save'), ['class' => 'btn btn-primary']) ?>
<?php if (!$model->isNewRecord): ?>
<?= Html::a(Yii::t('website', 'Delete'), Lookup::getLink($model, 'delete'), [
'class' => 'btn btn-danger',
<?= Html::a(Yii::t('website', 'Delete'), Lookup::getLink($model, 'delete'), ['class' => 'btn btn-danger',
'data-method' => 'post',
'data-confirm' => Yii::t('website', 'Are you sure you want to delete this item?'),
]) ?>
'data-confirm' => Yii::t('website', 'Are you sure you want to delete this item?'),]) ?>
<?php endif; ?>
</div>

Expand Down
5 changes: 4 additions & 1 deletion views/backend/page/update.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use \daxslab\website\components\Lookup;
use yii\helpers\Html;

$this->title = $model->title;
$this->params['breadcrumbs'] = Lookup::getBreadcrumbsForPage($model);
Expand All @@ -11,7 +12,9 @@

<header class="mb-4 pb-2 border-bottom">
<h1>
<?= $this->title ?> <small title="<?= Yii::t('website','Slug')?>" class="text-muted">(<?= $model->slug ?>)</small>
<?= $this->title ?>
<small title="<?= Yii::t('website', 'Slug') ?>" class="text-muted">(<?= $model->slug ?>)</small><br/>
<small><?= Html::a($model->url, $model->url, ['target' => '_blank']) ?></small>
</h1>
</header>

Expand Down

0 comments on commit bd1eb9b

Please sign in to comment.