diff --git a/modules/backend/widgets/Table.php b/modules/backend/widgets/Table.php index 6c7995cdf..c35f78ed4 100644 --- a/modules/backend/widgets/Table.php +++ b/modules/backend/widgets/Table.php @@ -101,22 +101,11 @@ class Table extends WidgetBase $columnName = Input::get('column'); $rowData = Input::get('rowData'); - traceLog($columnName); - traceLog($rowData); + $eventResults = $this->fireEvent('table.getDropdownOptions', [$columnName, $rowData]); - if ($rowData['billable'] == 'yes' || $rowData['billable'] == 'no') { - $options = [ - 'string'=>'String - '.$rowData['billable'], - 'checkbox'=>'Checkbox - '.$rowData['billable'], - 'dropdown'=>'Dropdown - '.$rowData['billable'] - ]; - } else { - $options = [ - 'who-knows'=>'Who knows?', - 'whatever'=>'Whatever', - 'sometimes'=>'Sometimes' - ]; - } + $options = []; + if (count($eventResults)) + $options = $eventResults[0]; return [ 'options' => $options diff --git a/modules/backend/widgets/table/README.md b/modules/backend/widgets/table/README.md index 30dba8b37..f0091247d 100644 --- a/modules/backend/widgets/table/README.md +++ b/modules/backend/widgets/table/README.md @@ -137,9 +137,21 @@ If the `options` element is not presented in the configuration, the options will **TODO:** Document the AJAX interface -**TODO:** Plan the option caching. Requirements: - - a) options could depend on other values in the current row. - - b) options could always be cached regardless of other values in the row. +The drop-down options could depend on other columns. This works only with AJAX-based drop-downs. The column a drop-down depends on are defined with the `depends_on` property: + + state: + title: State + type: dropdown + depends_on: country + +Multiple fields are allowed as well: + + state: + title: State + type: dropdown + depends_on: [country, language] + +**Note:** Dependent drop-down should always be defined after their master columns. # Server-side table widget (Backend\Widgets\Table) @@ -151,4 +163,22 @@ Columns are defined as array with the `columns` property. The array keys corresp - `type` (string, checkbox, dropdown, autocomplete) - `width` - sets the column width, can be specified in percents (10%) or pixels (50px). There could be a single column without the width specified. It will be stretched to take the available space. - `readonly` -- `options` (for drop-down elements and autocomplete types) \ No newline at end of file +- `options` (for drop-down elements and autocomplete types) +- `depends_on` (from drop-down elements) + +## Events + +### table.getDropdownOptions + +table.getDropdownOptions - triggered when drop-down options are requested by the client. Parameters: + +- `$columnName` - specifies the drop-down column name. +- `$rowData` - an array containing values of all columns in the table row. + +Example event handler: + + $table->bindEvent('table.getDropdownOptions', function ($columnName, $rowData) { + if ($columnName == 'state') + return ['ca'=>'California', 'wa'=>'Washington']; + ... + }); \ No newline at end of file diff --git a/plugins/cggstudio/loading/Plugin.php b/plugins/cggstudio/loading/Plugin.php deleted file mode 100755 index ba68982c6..000000000 --- a/plugins/cggstudio/loading/Plugin.php +++ /dev/null @@ -1,22 +0,0 @@ - 'cggstudio.loading::lang.plugin.name', - 'description' => "cggstudio.loading::lang.plugin.description", - 'author' => 'Carlos González Gurrea', - 'icon' => 'icon-refresh' - ]; - } - - public function registerComponents() - { - return [ - '\CGGStudio\Loading\Components\Loading' => 'Loading' - ]; - } -} -?> \ No newline at end of file diff --git a/plugins/cggstudio/loading/assets/css/default.css b/plugins/cggstudio/loading/assets/css/default.css deleted file mode 100755 index 4ada0389e..000000000 --- a/plugins/cggstudio/loading/assets/css/default.css +++ /dev/null @@ -1,26 +0,0 @@ -body { - overflow: hidden; -} - -#preloader { - - top:0; - left:0; - right:0; - bottom:0; - background-color:#fff; /* Seleccionar el color */ - z-index:999; /* Poner en la capa superior */ - position:fixed; -} - -#status { - background-image:url('../img/loading.gif'); - width:200px; - height:200px; - position:absolute; - left:50%; - top:50%; - background-repeat:no-repeat; - background-position:center; - margin:-100px 0 0 -100px; -} \ No newline at end of file diff --git a/plugins/cggstudio/loading/assets/img/loading.gif b/plugins/cggstudio/loading/assets/img/loading.gif deleted file mode 100755 index f4ff40eda..000000000 Binary files a/plugins/cggstudio/loading/assets/img/loading.gif and /dev/null differ diff --git a/plugins/cggstudio/loading/components/Loading.php b/plugins/cggstudio/loading/components/Loading.php deleted file mode 100755 index e064337ba..000000000 --- a/plugins/cggstudio/loading/components/Loading.php +++ /dev/null @@ -1,54 +0,0 @@ - 'Page loading indicator', - 'description' => "Adds a 'loading' to the page" - ]; - } - - public function defineProperties() - { - return [ - 'speedCGGStudio' => [ - 'title' => 'cggstudio.loading::lang.messages.Speed', - 'description' => 'cggstudio.loading::lang.messages.Speed_description', - 'default' => 300, - 'type' => 'string', - 'validationPattern' => '^[0-9]*$', - 'validationMessage' => 'cggstudio.loading::lang.messages.Speed_validation', - 'showExternalParameter' => false - ], - 'backgroundColorCGGStudio' => [ - 'title' => 'cggstudio.loading::lang.messages.Background', - 'description' => 'cggstudio.loading::lang.messages.Background_description', - 'default' => '#FFF', - 'type' => 'string', - 'validationPattern' => '#([a-fA-F0-9]){3}(([a-fA-F0-9]){3})?\b', - 'validationMessage' => 'cggstudio.loading::lang.messages.Background_validation', - 'showExternalParameter' => false - ], - - ]; - } - - public function onRun() - { - $this->Loading = new stdClass(); - $this->Loading->backgroundColor = $this->propertyOrParam('backgroundColorCGGStudio'); - $this->Loading->speed = $this->propertyOrParam('speedCGGStudio'); - $this->page['loading'] = $this->Loading; - - // Add css - $this->addCss('assets/css/default.css'); - - } -} \ No newline at end of file diff --git a/plugins/cggstudio/loading/components/loading/default.htm b/plugins/cggstudio/loading/components/loading/default.htm deleted file mode 100755 index 6238fd175..000000000 --- a/plugins/cggstudio/loading/components/loading/default.htm +++ /dev/null @@ -1,23 +0,0 @@ - -