From 7d8425538ba2aebd31cded35aa0d94845d5db018 Mon Sep 17 00:00:00 2001 From: flynsarmy Date: Fri, 26 Sep 2014 09:20:01 +1000 Subject: [PATCH 01/15] Send a 0 value when a checkbox is unchecked --- modules/backend/widgets/form/partials/_field_checkbox.htm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/backend/widgets/form/partials/_field_checkbox.htm b/modules/backend/widgets/form/partials/_field_checkbox.htm index 5b29d8eca..67675d46f 100644 --- a/modules/backend/widgets/form/partials/_field_checkbox.htm +++ b/modules/backend/widgets/form/partials/_field_checkbox.htm @@ -1,5 +1,10 @@
+ previewMode ? 'disabled="disabled"' : '' ?>> Date: Sat, 11 Oct 2014 08:44:30 +1100 Subject: [PATCH 02/15] We can't sort by relation fields anymore --- modules/backend/models/accesslog/columns.yaml | 14 +++++++++----- modules/backend/models/user/columns.yaml | 3 ++- modules/system/models/mailtemplate/columns.yaml | 3 ++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/modules/backend/models/accesslog/columns.yaml b/modules/backend/models/accesslog/columns.yaml index ecd6ae313..65c7133c8 100644 --- a/modules/backend/models/accesslog/columns.yaml +++ b/modules/backend/models/accesslog/columns.yaml @@ -10,8 +10,9 @@ columns: login: label: backend::lang.access_log.login relation: user - select: @login + select: login searchable: yes + sortable: false ip_address: label: backend::lang.access_log.ip_address @@ -20,17 +21,20 @@ columns: first_name: label: backend::lang.access_log.first_name relation: user - select: @first_name + select: first_name searchable: yes + sortable: false last_name: label: backend::lang.access_log.last_name relation: user - select: @last_name + select: last_name searchable: yes + sortable: false email: label: backend::lang.access_log.email relation: user - select: @email - searchable: yes \ No newline at end of file + select: email + searchable: yes + sortable: false \ No newline at end of file diff --git a/modules/backend/models/user/columns.yaml b/modules/backend/models/user/columns.yaml index 94aae5bcb..4bdec362f 100644 --- a/modules/backend/models/user/columns.yaml +++ b/modules/backend/models/user/columns.yaml @@ -22,4 +22,5 @@ columns: groups: label: backend::lang.user.groups relation: groups - select: @name \ No newline at end of file + select: name + sortable: false \ No newline at end of file diff --git a/modules/system/models/mailtemplate/columns.yaml b/modules/system/models/mailtemplate/columns.yaml index abd5985dd..5b9ac8207 100644 --- a/modules/system/models/mailtemplate/columns.yaml +++ b/modules/system/models/mailtemplate/columns.yaml @@ -19,4 +19,5 @@ columns: layout: label: system::lang.mail_templates.layout relation: layout - select: @name \ No newline at end of file + select: name + sortable: false \ No newline at end of file From 4504d5bf4c6011f5ae9facb797bac6ea0da98579 Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Sat, 11 Oct 2014 10:37:48 +1100 Subject: [PATCH 03/15] Improve translation handling --- .../backend/assets/js/october.inspector.js | 2 +- modules/backend/behaviors/FormController.php | 24 ++++++++++++------- modules/backend/lang/de/lang.php | 4 ++-- modules/backend/lang/en/lang.php | 13 ++++++---- modules/backend/lang/fa/lang.php | 4 ++-- .../backend/traits/InspectableContainer.php | 2 +- modules/backend/widgets/Form.php | 2 +- modules/cms/classes/ComponentHelpers.php | 13 +++++++--- modules/cms/formwidgets/Components.php | 4 ++++ .../components/partials/_component.htm | 10 ++++---- .../components/partials/_formcomponents.htm | 23 +++++++++--------- 11 files changed, 62 insertions(+), 39 deletions(-) diff --git a/modules/backend/assets/js/october.inspector.js b/modules/backend/assets/js/october.inspector.js index 88d4d13b9..a4baa7f33 100644 --- a/modules/backend/assets/js/october.inspector.js +++ b/modules/backend/assets/js/october.inspector.js @@ -587,7 +587,7 @@ // DROPDOWN EDITOR // ================== - + var InspectorEditorDropdown = function(editorId, inspector, fieldDef) { this.inspector = inspector this.fieldDef = fieldDef diff --git a/modules/backend/behaviors/FormController.php b/modules/backend/behaviors/FormController.php index e87683a2c..05754ef4e 100644 --- a/modules/backend/behaviors/FormController.php +++ b/modules/backend/behaviors/FormController.php @@ -107,6 +107,17 @@ class FormController extends ControllerBehavior */ if ($this->controller->isClassExtendedWith('Backend.Behaviors.RelationController')) $this->controller->initRelation($model); + + $this->prepareVars($model); + } + + /** + * Prepares common form data + */ + protected function prepareVars($model) + { + $this->controller->vars['formModel'] = $model; + $this->controller->vars['formRecordName'] = Lang::get($this->getConfig('name', 'backend::lang.model.name')); } // @@ -124,9 +135,8 @@ class FormController extends ControllerBehavior $this->context = strlen($context) ? $context : $this->getConfig('create[context]', 'create'); $this->controller->pageTitle = $this->controller->pageTitle ?: $this->getLang('create[title]', 'backend::lang.form.create_title'); $model = $this->controller->formCreateModelObject(); - $this->initForm($model); - $this->controller->vars['formModel'] = $model; + $this->initForm($model); } catch (Exception $ex) { $this->controller->handleError($ex); @@ -176,9 +186,8 @@ class FormController extends ControllerBehavior $this->context = strlen($context) ? $context : $this->getConfig('update[context]', 'update'); $this->controller->pageTitle = $this->controller->pageTitle ?: $this->getLang('update[title]', 'backend::lang.form.update_title'); $model = $this->controller->formFindModelObject($recordId); - $this->initForm($model); - $this->controller->vars['formModel'] = $model; + $this->initForm($model); } catch (Exception $ex) { $this->controller->handleError($ex); @@ -250,9 +259,8 @@ class FormController extends ControllerBehavior $this->context = strlen($context) ? $context : $this->getConfig('preview[context]', 'preview'); $this->controller->pageTitle = $this->controller->pageTitle ?: $this->getLang('preview[title]', 'backend::lang.form.preview_title'); $model = $this->controller->formFindModelObject($recordId); - $this->initForm($model); - $this->controller->vars['formModel'] = $model; + $this->initForm($model); } catch (Exception $ex) { $this->controller->handleError($ex); @@ -353,10 +361,10 @@ class FormController extends ControllerBehavior { $name = $this->getConfig($name, $default); $vars = [ - 'name' => Lang::get($this->getConfig('name', trans('backend::lang.model.name'))) + 'name' => Lang::get($this->getConfig('name', 'backend::lang.model.name')) ]; $vars = array_merge($vars, $extras); - return trans($name, $vars); + return Lang::get($name, $vars); } // diff --git a/modules/backend/lang/de/lang.php b/modules/backend/lang/de/lang.php index c9a1b0796..ee851ae68 100644 --- a/modules/backend/lang/de/lang.php +++ b/modules/backend/lang/de/lang.php @@ -163,8 +163,8 @@ return [ 'select_placeholder' => 'Bitte auswählen', 'insert_row' => 'Reihe einfügen', 'delete_row' => 'Reihe löschen', - 'concurrency-file-changed-title' => 'Datei wurde geändert', - 'concurrency-file-changed-description' => 'Die Datei, welche Sie bearbeiten, wurde auf von einem anderen Benutzer geändert. Sie können die Datei entweder erneut laden, wodurch Ihre Änderungen verloren gehen oder Sie überschreiben die Datei auf dem Server', + 'concurrency_file_changed_title' => 'Datei wurde geändert', + 'concurrency_file_changed_description' => 'Die Datei, welche Sie bearbeiten, wurde auf von einem anderen Benutzer geändert. Sie können die Datei entweder erneut laden, wodurch Ihre Änderungen verloren gehen oder Sie überschreiben die Datei auf dem Server', 'reload' => 'Erneut laden', ], 'relation' => [ diff --git a/modules/backend/lang/en/lang.php b/modules/backend/lang/en/lang.php index 4442ad9f0..2243df5f3 100644 --- a/modules/backend/lang/en/lang.php +++ b/modules/backend/lang/en/lang.php @@ -139,14 +139,18 @@ return [ 'missing_model' => 'Form behavior used in :class does not have a model defined.', 'missing_definition' => "Form behavior does not contain a field for ':field'.", 'not_found' => 'Form record with an ID of :id could not be found.', + 'action_confirm' => "Are you sure?", 'create' => 'Create', 'create_and_close' => 'Create and close', 'creating' => 'Creating...', + 'creating_name' => 'Creating :name...', 'save' => 'Save', 'save_and_close' => 'Save and close', 'saving' => 'Saving...', + 'saving_name' => 'Saving :name...', 'delete' => 'Delete', 'deleting' => 'Deleting...', + 'deleting_name' => 'Deleting :name...', 'undefined_tab' => 'Misc', 'field_off' => 'Off', 'field_on' => 'On', @@ -154,6 +158,8 @@ return [ 'apply' => 'Apply', 'cancel' => 'Cancel', 'close' => 'Close', + 'confirm' => 'Confirm', + 'reload' => 'Reload', 'ok' => 'OK', 'or' => 'or', 'confirm_tab_close' => 'Do you really want to close the tab? Unsaved changes will be lost.', @@ -165,16 +171,15 @@ return [ 'select_placeholder' => 'please select', 'insert_row' => 'Insert Row', 'delete_row' => 'Delete Row', - 'concurrency-file-changed-title' => 'File was changed', - 'concurrency-file-changed-description' => 'The file you\'re editing has been changed on disk by another user. You can either reload the file and lose your changes or override the file on the disk.', - 'reload' => 'Reload', + 'concurrency_file_changed_title' => "File was changed", + 'concurrency_file_changed_description' => "The file you're editing has been changed on disk by another user. You can either reload the file and lose your changes or override the file on the disk.", ], 'relation' => [ 'missing_definition' => "Relation behavior does not contain a definition for ':field'.", 'missing_model' => "Relation behavior used in :class does not have a model defined.", 'invalid_action_single' => "This action cannot be performed on a singular relationship.", 'invalid_action_multi' => "This action cannot be performed on a multiple relationship.", - 'help' => "Click on an item to add", + 'help' => "Click on an item to add", 'related_data' => "Related :name data", 'add' => "Add", 'add_selected' => "Add selected", diff --git a/modules/backend/lang/fa/lang.php b/modules/backend/lang/fa/lang.php index 96571f99d..9c40d06c1 100644 --- a/modules/backend/lang/fa/lang.php +++ b/modules/backend/lang/fa/lang.php @@ -165,8 +165,8 @@ return [ 'select_placeholder' => 'لطفا انتخاب نمایید', 'insert_row' => 'افزودن سطر', 'delete_row' => 'حذف سطر', - 'concurrency-file-changed-title' => 'فایل تغییر کرد', - 'concurrency-file-changed-description' => 'فایلی که شما ویرایش کردید توسط کاربر دیگری تغییر یافته و ذخیره شده است. شما میتوانید فایل را مجددا بارگذاری نمایید و تغییراتی که اعمال کرده اید را از دست بدهید و یا تغییرات اعمال شده توسط آن کاربر را بین برده و فایل را بازنویسی نمایید.', + 'concurrency_file_changed_title' => 'فایل تغییر کرد', + 'concurrency_file_changed_description' => 'فایلی که شما ویرایش کردید توسط کاربر دیگری تغییر یافته و ذخیره شده است. شما میتوانید فایل را مجددا بارگذاری نمایید و تغییراتی که اعمال کرده اید را از دست بدهید و یا تغییرات اعمال شده توسط آن کاربر را بین برده و فایل را بازنویسی نمایید.', 'reload' => 'بارگذاری مجدد', ], 'relation' => [ diff --git a/modules/backend/traits/InspectableContainer.php b/modules/backend/traits/InspectableContainer.php index 3b6eb64ca..90a2bea73 100644 --- a/modules/backend/traits/InspectableContainer.php +++ b/modules/backend/traits/InspectableContainer.php @@ -1,8 +1,8 @@ $value) { - if (!in_array($name, $translate)) continue; - $property[$name] = Lang::get($value); + if (!in_array($name, $translate)) + continue; + + if (is_array($value)) { + array_walk($property[$name], function(&$_value, $key) { $_value = Lang::get($_value); }); + } + else { + $property[$name] = Lang::get($value); + } } $result[] = $property; diff --git a/modules/cms/formwidgets/Components.php b/modules/cms/formwidgets/Components.php index a3f6014c0..5c94c9305 100644 --- a/modules/cms/formwidgets/Components.php +++ b/modules/cms/formwidgets/Components.php @@ -44,12 +44,16 @@ class Components extends FormWidgetBase $componentObj->alias = $alias; $componentObj->pluginIcon = 'icon-puzzle-piece'; + /* + * Look up the plugin hosting this component + */ $plugin = $manager->findComponentPlugin($componentObj); if ($plugin) { $pluginDetails = $plugin->pluginDetails(); if (isset($pluginDetails['icon'])) $componentObj->pluginIcon = $pluginDetails['icon']; } + } catch (Exception $ex) { $componentObj = new UnknownComponent(null, $properties, $ex->getMessage()); diff --git a/modules/cms/formwidgets/components/partials/_component.htm b/modules/cms/formwidgets/components/partials/_component.htm index 41f5834ec..0707d8ba9 100644 --- a/modules/cms/formwidgets/components/partials/_component.htm +++ b/modules/cms/formwidgets/components/partials/_component.htm @@ -1,6 +1,6 @@
-
inspectorEnabled): ?>data-inspectable data-inspector-title="getComponentName($component)) ?>" data-inspector-description="getComponentDescription($component)) ?>" @@ -9,9 +9,9 @@ alias) ?> - - - + + + ×
\ No newline at end of file diff --git a/modules/cms/formwidgets/components/partials/_formcomponents.htm b/modules/cms/formwidgets/components/partials/_formcomponents.htm index 51af8f844..842d04771 100644 --- a/modules/cms/formwidgets/components/partials/_formcomponents.htm +++ b/modules/cms/formwidgets/components/partials/_formcomponents.htm @@ -1,18 +1,17 @@
- isHidden) - echo $this->makePartial('component', ['component'=>$component]); - } - ?> + + isHidden): ?> + makePartial('component', ['component' => $component]) ?> + + +
- isHidden) - echo $this->makePartial('component', ['component'=>$component]); - } - ?> + + isHidden): ?> + makePartial('component', ['component' => $component]) ?> + +
From 1dcaa0d1d6a8d5ba1bd18da4327b0f4944df8095 Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Sat, 11 Oct 2014 12:13:25 +1100 Subject: [PATCH 04/15] Fixes #677 - use FQN for "instanceof Model" expressions --- modules/backend/widgets/Form.php | 2 +- modules/cms/twig/DebugExtension.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/backend/widgets/Form.php b/modules/backend/widgets/Form.php index 74492f3d5..928144bc6 100644 --- a/modules/backend/widgets/Form.php +++ b/modules/backend/widgets/Form.php @@ -3,7 +3,6 @@ use App; use Str; use Lang; -use Model; use Form as FormHelper; use Input; use Event; @@ -12,6 +11,7 @@ use Backend\Classes\WidgetBase; use Backend\Classes\WidgetManager; use System\Classes\ApplicationException; use Backend\Classes\FormWidgetBase; +use October\Rain\Database\Model; /** * Form Widget diff --git a/modules/cms/twig/DebugExtension.php b/modules/cms/twig/DebugExtension.php index 9546fbd5b..52dc460f1 100644 --- a/modules/cms/twig/DebugExtension.php +++ b/modules/cms/twig/DebugExtension.php @@ -7,7 +7,7 @@ use Cms\Classes\Controller; use Cms\Classes\ComponentBase; use Illuminate\Pagination\Paginator; use Illuminate\Support\Collection; -use Model; +use October\Rain\Database\Model; class DebugExtension extends Twig_Extension { From 3836a9b8d7e44b1ec12809a500642a45849ba199 Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Sat, 11 Oct 2014 12:27:21 +1100 Subject: [PATCH 05/15] Refs #679 - Fixed Visibility must be declared on property issues --- modules/backend/classes/AuthManager.php | 6 +++--- modules/backend/classes/NavigationManager.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/backend/classes/AuthManager.php b/modules/backend/classes/AuthManager.php index 41b992f76..c8dfcb43b 100644 --- a/modules/backend/classes/AuthManager.php +++ b/modules/backend/classes/AuthManager.php @@ -27,7 +27,7 @@ class AuthManager extends RainAuthManager // Permission management // - static $permissionDefaults = [ + protected static $permissionDefaults = [ 'code' => null, 'label' => null, 'comment' => null, @@ -82,8 +82,8 @@ class AuthManager extends RainAuthManager { foreach ($definitions as $code=>$definition) { $permission = (object)array_merge(self::$permissionDefaults, array_merge($definition, [ - 'code'=>$code, - 'owner'=>$owner + 'code' => $code, + 'owner' => $owner ])); $this->permissions[] = $permission; diff --git a/modules/backend/classes/NavigationManager.php b/modules/backend/classes/NavigationManager.php index 8b21c68f4..a65f8726a 100644 --- a/modules/backend/classes/NavigationManager.php +++ b/modules/backend/classes/NavigationManager.php @@ -30,7 +30,7 @@ class NavigationManager protected $contextMainMenuItemCode; protected $contextSideMenuItemCode; - static $mainItemDefaults = [ + protected static $mainItemDefaults = [ 'code' => null, 'label' => null, 'icon' => null, @@ -40,7 +40,7 @@ class NavigationManager 'sideMenu' => [] ]; - static $sideItemDefaults = [ + protected static $sideItemDefaults = [ 'code' => null, 'label' => null, 'icon' => null, From 543f1616b7f64b3d1fcee33c506f9c81352e48bb Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Sat, 11 Oct 2014 12:31:14 +1100 Subject: [PATCH 06/15] Fixes 675 - Add |trans (Lang::get) and |transchoice (Lang::choice) filters --- modules/system/ServiceProvider.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/system/ServiceProvider.php b/modules/system/ServiceProvider.php index 94cf56830..88c6c64af 100644 --- a/modules/system/ServiceProvider.php +++ b/modules/system/ServiceProvider.php @@ -213,6 +213,8 @@ class ServiceProvider extends ModuleServiceProvider 'snake' => ['Str', 'snake'], 'camel' => ['Str', 'camel'], 'studly' => ['Str', 'studly'], + 'trans' => ['Lang', 'get'], + 'transchoice' => ['Lang', 'choice'], 'md' => ['October\Rain\Support\Markdown', 'parse'], ]); }); From 7d313a0409884b62d014fa860a72814bc624f4a3 Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Sat, 11 Oct 2014 13:43:00 +1100 Subject: [PATCH 07/15] Update changelog and Fixes #582 --- CHANGELOG.md | 3 +++ modules/system/controllers/updates/_disable_form.htm | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6d2f16ed..e419ff0b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +* **Build 15x** (2014-10-x) + - Added twig filters `|trans` for `Lang::get(...)` and `|transchoice` for `Lang::choice(...)`. + * **Build 153** (2014-10-09) - Plugins are now updated in order of their dependency definitions. - Moved `ViewMaker` trait now lives under system, it can be useful for Models too. diff --git a/modules/system/controllers/updates/_disable_form.htm b/modules/system/controllers/updates/_disable_form.htm index a6aa37e65..5f116dfda 100644 --- a/modules/system/controllers/updates/_disable_form.htm +++ b/modules/system/controllers/updates/_disable_form.htm @@ -41,7 +41,7 @@ type="submit" class="btn btn-primary" data-request="onDisablePlugins" - data-request-confirm="" + data-request-confirm="" data-stripe-load-indicator> From 71f9df8e136cb15a49605749a629218171cb7eb7 Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Sat, 11 Oct 2014 14:31:09 +1100 Subject: [PATCH 08/15] Use HTML to pass unchecked checkboxes/switches. Refs #648 --- modules/backend/widgets/Form.php | 9 +++------ .../backend/widgets/form/partials/_field_checkbox.htm | 2 +- modules/backend/widgets/form/partials/_field_switch.htm | 7 ++++++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/backend/widgets/Form.php b/modules/backend/widgets/Form.php index 928144bc6..8efc7d7c6 100644 --- a/modules/backend/widgets/Form.php +++ b/modules/backend/widgets/Form.php @@ -693,12 +693,10 @@ class Form extends WidgetBase $data = []; /* - * Boolean fields (checkbox, switch) won't be present value FALSE * Number fields should be converted to integers */ foreach ($this->fields as $field) { - - if (!in_array($field->type, ['switch', 'checkbox', 'number'])) + if ($field->type != 'number') continue; /* @@ -706,11 +704,10 @@ class Form extends WidgetBase */ $parts = Str::evalHtmlArray($field->fieldName); $dotted = implode('.', $parts); - $value = array_get($data, $dotted, 0); - if ($field->type == 'number') { + if (($value = array_get($data, $dotted)) !== null) { $value = !strlen(trim($value)) ? null : (float) $value; + array_set($data, $dotted, $value); } - array_set($data, $dotted, $value); } /* diff --git a/modules/backend/widgets/form/partials/_field_checkbox.htm b/modules/backend/widgets/form/partials/_field_checkbox.htm index 5d91128aa..962501a34 100644 --- a/modules/backend/widgets/form/partials/_field_checkbox.htm +++ b/modules/backend/widgets/form/partials/_field_checkbox.htm @@ -4,7 +4,7 @@ type="hidden" name="getName() ?>" value="0" - previewMode ? 'disabled="disabled"' : '' ?>> + previewMode ? 'disabled="disabled"' : '' ?>> comment)) ?>

-