From baee9edcd2fb65001641cc20c2018a5c5c6cc3ea Mon Sep 17 00:00:00 2001 From: alekseybobkov Date: Wed, 10 Dec 2014 19:49:50 -0800 Subject: [PATCH] Implemented server-side drop-down event, updated documentation. --- modules/backend/widgets/Table.php | 19 ++---- modules/backend/widgets/table/README.md | 38 ++++++++++-- plugins/cggstudio/loading/Plugin.php | 22 ------- .../cggstudio/loading/assets/css/default.css | 26 --------- .../cggstudio/loading/assets/img/loading.gif | Bin 8581 -> 0 bytes .../cggstudio/loading/components/Loading.php | 54 ------------------ .../loading/components/loading/default.htm | 23 -------- plugins/cggstudio/loading/lang/en/lang.php | 16 ------ plugins/cggstudio/loading/lang/es/lang.php | 16 ------ plugins/cggstudio/loading/readme.md | 23 -------- .../cggstudio/loading/updates/version.yaml | 1 - 11 files changed, 38 insertions(+), 200 deletions(-) delete mode 100755 plugins/cggstudio/loading/Plugin.php delete mode 100755 plugins/cggstudio/loading/assets/css/default.css delete mode 100755 plugins/cggstudio/loading/assets/img/loading.gif delete mode 100755 plugins/cggstudio/loading/components/Loading.php delete mode 100755 plugins/cggstudio/loading/components/loading/default.htm delete mode 100755 plugins/cggstudio/loading/lang/en/lang.php delete mode 100755 plugins/cggstudio/loading/lang/es/lang.php delete mode 100755 plugins/cggstudio/loading/readme.md delete mode 100755 plugins/cggstudio/loading/updates/version.yaml 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 f4ff40edab88c7df20db106d35c641723d125f56..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8581 zcma*sX;f3^+6LgAoq>$7LqZY;F%uzRfFxuBX&ZI|q96^3iV8Lail}HoK~bp&NFoSY zP*j`)q9UapR8(+k7_?}qBI1m#C}OqRqaNGS_VjDNm&Q_$)wK?P;fJnuJ@>w!=bbPy zS`(JWg}Bfj2*SZQOR=S^qf3wKhwct#m@?|?>V+a1#hQwq^F48s;vPSGoINkQsj+F`=0M8KlwW`OwQzai$>S%fWU3@svVH6Ji0}v; z0cWvUy3Tg#qxD0>Lm8PF^?U0jfs+2K{Ylf3Ui|nXZ%JOu(U$5>)e4ou$JeJ~T}97@ zp1An9$KOBBUYOl^R1LJ9c_URGd!&_ zoN9G5#HkUsBqyBA-vaLl;<#AH=*T$S+;EuB$C4B?s9Qq3%wup?A9Xkfr&O|VC>?w9 z3SO!f`UFWE`@(%~JPw1^dr_eCb3b{N#^K%32aIdI_}~F8B2UaGd*c85i;W_I71&;^%Lxse3K`0&wMsow+lG^kNiE5cw*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ZR|k*~GBEqI!iG*K0Vpo`Cb=r>`HfO=v&AO%mCgMX#Il<3%D~ zau&iwLc}^G#)Do}oVnH1X~--^>du@Kaic3@a*s?}gX0liY~M6&o%R`=LEo>9Y41q;+M;qpYv{fh>|O-OvL5C zpvc}L@{>VKHv$h`H7A~CW?e$W{W(|~3;$=682`pj{OZf~E0V$IeB>^%soGhKN3Uvc zd$}Gd6J#n72#Ah0iC15)L75oE4B9a83`PKi^5|jhZO_&KGnkIo`Z4IlBahOy2p=7g z952$7pgX*qQn1wR9xt`E1QxoNjEX9;feQZ6JzowsWso)-`abo3AHd;->m~lTD8Wi}+aUCu7-nT3Z4) zPlN?hJJNpWK1AQtZ1v?rFa% z9qx(>kRDGnRLTxR%R^x|r3*cGz>AsMT!LMwVUnBG9wGTl%#tR++>_ ziZPZ4_z+ZUhD;q5m;LIW#H3*+SW;2W-JhB|tTfDt)C#WAZov@h`K*M>L6zn '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 @@ - -
-
 
-
- - - - - \ No newline at end of file diff --git a/plugins/cggstudio/loading/lang/en/lang.php b/plugins/cggstudio/loading/lang/en/lang.php deleted file mode 100755 index 5dc597830..000000000 --- a/plugins/cggstudio/loading/lang/en/lang.php +++ /dev/null @@ -1,16 +0,0 @@ - [ -'name' => 'Page loading indicator', -'description' => 'Adds a "loading" to the pages.', -], -'messages' => [ -'Speed' => 'Speed', -'Speed_description' => 'Time taken for loading logo once the page load disappear', -'Speed_validation' => 'The "Speed" property can contain only numeric symbols', -'Background' => 'Background Color', -'Background_description' => 'CSS color attribute of the background', -'Background_validation' => 'The "Background Color" needs to be a hex color code' -], -]; -?> \ No newline at end of file diff --git a/plugins/cggstudio/loading/lang/es/lang.php b/plugins/cggstudio/loading/lang/es/lang.php deleted file mode 100755 index 8527a229e..000000000 --- a/plugins/cggstudio/loading/lang/es/lang.php +++ /dev/null @@ -1,16 +0,0 @@ - [ -'name' => 'Cargando', -'description' => 'Añade una logo de carga a la página', -], -'messages' => [ -'Speed' => 'Velocidad', -'Speed_description' => 'Tiempo que tarda en minisegungos en quitarse el icono de cargando una vez cargada la página', -'Speed_validation' => 'La velocidad solo puede contener numeros', -'Background' => 'Color de fondo', -'Background_description' => 'Color de fondo de la precargar', -'Background_validation' => 'El color tiene que ser hexadecimal' -], -]; -?> \ No newline at end of file diff --git a/plugins/cggstudio/loading/readme.md b/plugins/cggstudio/loading/readme.md deleted file mode 100755 index 4d5e1200c..000000000 --- a/plugins/cggstudio/loading/readme.md +++ /dev/null @@ -1,23 +0,0 @@ -# Loading -This plugin adds a 'Loading' integration features to [OctoberCMS](http://octobercms.com). - - -### Available options: -* **Speed**: Time taken for loading logo once the page load disappear -* **Background**: Color Background - -## Documentation -In many templates or pages we wait for this all information loaded to display the page. This is what makes this plugin, put the logo of loading until it has completed the full page load. -It adds the **Loading** object to the page, which contains all the information the Component needs to function as you customized it. - -### Quickstart guide: -1. Go to the 'System' tab in October, and install the plugin using the **CGGStudio.Loading** code. -2. After installation has finished a new component will appear in under Octobers 'CMS > Components' tab. You have the option to add this to only one page, or add it to a layout making it appear on all pages that use the layout. Whichever you chose the instructions are the same. -3. Open the your selected page/layout, and add the component to it. -4. Add this small code anywhere on the page/layout: -``` {% component 'Loading' %} ``` Be sure to use the correct alias, if you haven't changed it, then it should be 'Loading'. The position of the code doesn't really count, since the arrow has a fixed position. -5. That's it. You now have a working 'Loading' button on your page. It has no outside dependencies, so you don't have to worry about anything else. - -### Colors: -The Component requires you to add the hex color codes you prefer. -This free online application can help you with that: http://www.colorpicker.com/ \ No newline at end of file diff --git a/plugins/cggstudio/loading/updates/version.yaml b/plugins/cggstudio/loading/updates/version.yaml deleted file mode 100755 index 51bc2be6d..000000000 --- a/plugins/cggstudio/loading/updates/version.yaml +++ /dev/null @@ -1 +0,0 @@ -1.0.1: First version \ No newline at end of file