]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Change way of working directive renderer
authorMarcin Haba <marcin.haba@bacula.pl>
Sun, 4 Aug 2019 08:49:06 +0000 (10:49 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Sat, 14 Dec 2019 14:55:28 +0000 (15:55 +0100)
16 files changed:
gui/baculum/protected/Web/Pages/JobHistoryView.page
gui/baculum/protected/Web/Pages/JobView.page
gui/baculum/protected/Web/Portlets/DirectiveCheckBox.tpl
gui/baculum/protected/Web/Portlets/DirectiveComboBox.tpl
gui/baculum/protected/Web/Portlets/DirectiveInteger.tpl
gui/baculum/protected/Web/Portlets/DirectiveListBox.tpl
gui/baculum/protected/Web/Portlets/DirectiveMultiComboBox.tpl
gui/baculum/protected/Web/Portlets/DirectiveMultiTextBox.tpl
gui/baculum/protected/Web/Portlets/DirectivePassword.tpl
gui/baculum/protected/Web/Portlets/DirectiveRenderer.php
gui/baculum/protected/Web/Portlets/DirectiveSize.tpl
gui/baculum/protected/Web/Portlets/DirectiveSpeed.tpl
gui/baculum/protected/Web/Portlets/DirectiveTextBox.tpl
gui/baculum/protected/Web/Portlets/DirectiveTimePeriod.tpl
gui/baculum/protected/Web/Portlets/FileSetBrowser.php
gui/baculum/protected/Web/Portlets/FileSetBrowser.tpl

index 5468ff2c0a752d493bc15f4280d1a79cbb19afd2..cb7a83c2d7d565d114c6bec8bea1b4fe74c5c70d 100644 (file)
@@ -16,7 +16,6 @@
                        Text="<%[ Configure job ]%>"
                        Visible="<%=!empty($_SESSION['dir'])%>"
                        OnClick="loadJobConfig"
-                       CommandParameter="show"
                />
                <com:TActiveLinkButton
                        CssClass="w3-bar-item w3-button tab_btn"
@@ -24,7 +23,6 @@
                        Text="<%[ Configure fileset ]%>"
                        Visible="<%=!empty($_SESSION['dir'])%>"
                        OnClick="loadFileSetConfig"
-                       CommandParameter="show"
                />
                <com:TActiveLinkButton
                        CssClass="w3-bar-item w3-button tab_btn"
@@ -32,7 +30,6 @@
                        Text="<%[ Configure schedule ]%>"
                        Visible="<%=!empty($_SESSION['dir'])%>"
                        OnClick="loadScheduleConfig"
-                       CommandParameter="show"
                />
        </div>
        <div class="w3-container tab_item" id="job_actions">
index a79f5c1a887c41f04823009626a0d50860efc153..95310957b3b49e67cc8ec4615ca4729df760d98e 100644 (file)
@@ -16,7 +16,6 @@
                        Text="<%[ Configure job ]%>"
                        Visible="<%=!empty($_SESSION['dir'])%>"
                        OnClick="loadJobConfig"
-                       CommandParameter="show"
                />
                <com:TActiveLinkButton
                        CssClass="w3-bar-item w3-button tab_btn"
@@ -24,7 +23,6 @@
                        Text="<%[ Configure fileset ]%>"
                        Visible="<%=!empty($_SESSION['dir'])%>"
                        OnClick="loadFileSetConfig"
-                       CommandParameter="show"
                />
                <com:TActiveLinkButton
                        CssClass="w3-bar-item w3-button tab_btn"
                        Text="<%[ Configure schedule ]%>"
                        Visible="<%=!empty($_SESSION['dir'])%>"
                        OnClick="loadScheduleConfig"
-                       CommandParameter="show"
                />
                <com:TActiveLinkButton
                        CssClass="w3-bar-item w3-button tab_btn"
                        Text="<%[ Job schedules ]%>"
                        OnCallback="loadSchedules"
-                       CommandParameter="show"
                        Attributes.onclick="W3Tabs.open(this.id, 'job_schedules'); clear_node('#job_config div.directive_field'); clear_node('#fileset_config div.directive_field'); clear_node('#schedule_config  div.directive_field');"
                />
        </div>
index 27e7a8337ef9baf9f2b7340142df53f70f78c003..dd124839b47582fadccff5427ef18f56c13912c2 100644 (file)
@@ -1,4 +1,4 @@
-<div class="w3-row w3-margin-bottom<%=!$this->display_directive ? ' hide' : '';%>">
+<div class="directive_field w3-row w3-margin-bottom<%=!$this->display_directive ? ' hide' : '';%>">
        <div class="w3-col w3-quarter"><com:TActiveLabel ID="Label" ActiveControl.EnableUpdate="false" Visible="<%=$this->display_directive%>" />:</div>
        <div class="w3-col w3-threequarter directive_value">
                <com:TActiveCheckBox
index 217be8b8bcfa60b4b39e9d3d56a8f4cc3d796eed..c6258743a784e07a69205f7f57911719f0d1eca6 100644 (file)
@@ -1,4 +1,4 @@
-<div class="w3-row w3-margin-bottom<%=!$this->display_directive ? ' hide' : '';%>">
+<div class="directive_field w3-row w3-margin-bottom<%=!$this->display_directive ? ' hide' : '';%>">
        <div class="w3-col w3-quarter"><com:TActiveLabel ID="Label" ActiveControl.EnableUpdate="false" Visible="<%=$this->display_directive%>" />:</div>
        <div class="w3-col w3-threequarter directive_value">
                <com:TActiveDropDownList ID="Directive"
index 9714de267eb2ca1c763179602c60131618b531eb..d81d0bb277456b9ae88b6a7953012e544be884b0 100644 (file)
@@ -1,4 +1,4 @@
-<div class="w3-row w3-margin-bottom<%=!$this->display_directive ? ' hide' : '';%>">
+<div class="directive_field w3-row w3-margin-bottom<%=!$this->display_directive ? ' hide' : '';%>">
        <div class="w3-col w3-quarter"><com:TActiveLabel ID="Label" ActiveControl.EnableUpdate="false" Visible="<%=$this->display_directive%>" />:</div>
        <div class="w3-col w3-threequarter directive_value">
                <com:TActiveTextBox ID="Directive"
index da92f9e020842c49417285fc8aba20322e01a179..5172e38325a3d573634962fd69faddb89f10d5cc 100644 (file)
@@ -1,4 +1,4 @@
-<div class="w3-row w3-margin-bottom<%=!$this->display_directive ? ' hide' : '';%>">
+<div class="directive_field w3-row w3-margin-bottom<%=!$this->display_directive ? ' hide' : '';%>">
        <div class="w3-col w3-quarter"><com:TActiveLabel ID="Label" ActiveControl.EnableUpdate="false" Visible="<%=$this->display_directive%>" />:</div>
        <div class="w3-col w3-threequarter directive_value">
                <com:TActiveListBox ID="Directive"
index 6929a793e2a41492c0a8dcca4856a1ee207dabab..b13832528eb59a1617503e8739c0913cd5596605 100644 (file)
@@ -1,6 +1,6 @@
 <com:TActiveRepeater ID="MultiComboBoxRepeater" OnItemDataBound="createMultiComboBoxElement">
        <prop:ItemTemplate>
-               <div class="w3-row w3-margin-bottom<%=!$this->Data['show'] ? ' hide' : '';%>">
+               <div class="directive_field w3-row w3-margin-bottom<%=!$this->Data['show'] ? ' hide' : '';%>">
                        <div class="w3-col w3-quarter"><com:TActiveLabel ID="Label" ActiveControl.EnableUpdate="false" />:</div>
                        <div class="w3-col w3-threequarter directive_value">
                                <com:TActiveDropDownList ID="Directive"
index 84e647a9b6d10f5fbaac509b734f1218a33aa011..3247c81e1f1812c108e5ac04f88a97d9f69d40d6 100644 (file)
@@ -1,6 +1,6 @@
 <com:TActiveRepeater ID="MultiTextBoxRepeater" OnItemDataBound="createMultiTextBoxElement">
        <prop:ItemTemplate>
-               <div class="w3-row w3-margin-bottom<%=!$this->Data['show'] ? ' hide' : '';%>">
+               <div class="directive_field w3-row w3-margin-bottom<%=!$this->Data['show'] ? ' hide' : '';%>">
                        <div class="w3-col w3-quarter"><com:TActiveLabel ID="Label" ActiveControl.EnableUpdate="false" />:</div>
                        <div class="w3-col w3-threequarter directive_value">
                                <com:TActiveTextBox ID="Directive"
index 259b4e398646bee1fdffa5fc72f436a73d973507..5841566ea111b8663a94f8bbf81b2b8e0dad4475 100644 (file)
@@ -1,4 +1,4 @@
-<div class="w3-row w3-margin-bottom<%=!$this->display_directive ? ' hide' : '';%>">
+<div class="directive_field w3-row w3-margin-bottom<%=!$this->display_directive ? ' hide' : '';%>">
        <div class="w3-col w3-quarter"><com:TActiveLabel ID="Label" ActiveControl.EnableUpdate="false" Visible="<%=$this->display_directive%>" />:</div>
        <div class="w3-col w3-threequarter directive_value">
                <com:TActiveTextBox ID="Directive"
index 7cc69308bfa6ad8d3b839092d268c7d2541ae260..6245a993ec69ad72516fae5adac5e272729ff2e8 100644 (file)
@@ -39,10 +39,9 @@ Prado::using('Application.Web.Portlets.DirectiveTimePeriod');
 Prado::using('Application.Web.Portlets.DirectiveRunscript');
 Prado::using('Application.Web.Portlets.DirectiveMessages');
 
-class DirectiveRenderer extends DirectiveListTemplate implements IItemDataRenderer {
+class DirectiveRenderer extends DirectiveListTemplate implements IDataRenderer {
 
        const DATA = 'Data';
-       const ITEM_INDEX = 'ItemIndex';
 
        private $directive_types = array(
                'DirectiveCheckBox',
@@ -69,8 +68,20 @@ class DirectiveRenderer extends DirectiveListTemplate implements IItemDataRender
 
        public function onLoad($param) {
                parent::onLoad($param);
+               $this->createItemInternal();
+       }
+
+       public function createItemInternal() {
                $data = $this->getData();
-               $this->createItem($data);
+               $item = $this->createItem($data);
+
+               $this->addParsedObject($item);
+
+               if ($item instanceof DirectiveTemplate) {
+                       $item->createDirective();
+               } elseif ($item instanceof DirectiveListTemplate) {
+                       $item->loadConfig(null, null);
+               }
        }
 
        public function createItem($data) {
@@ -96,8 +107,6 @@ class DirectiveRenderer extends DirectiveListTemplate implements IItemDataRender
                        $control->setGroupName($data['group_name']);
                        $control->setParentName($data['parent_name']);
                        $control->setResourceNames($this->SourceTemplateControl->getResourceNames());
-                       $this->getControls()->add($control);
-                       $control->createDirective();
                } elseif (in_array($type, $this->directive_list_types)) {
                        $control->setHost($data['host']);
                        $control->setComponentType($data['component_type']);
@@ -112,29 +121,8 @@ class DirectiveRenderer extends DirectiveListTemplate implements IItemDataRender
                        $control->setShow($data['show']);
                        $control->setGroupName($data['group_name']);
                        $control->setResource($data['resource']);
-                       $this->getControls()->add($control);
-                       if (!$this->getPage()->IsCallBack || $this->getPage()->getCallbackEventParameter()  === 'show_all_directives' || $this->getCmdParam() === 'show') {
-                               /*
-                                * List types should be loaded only by load request, not by callback request.
-                                * Otherwise OnLoad above is called during callback and overwrites data in controls.
-                                */
-                               $control->raiseEvent('OnDirectiveListLoad', $this, null);
-                       }
                }
-       }
-
-       public function getItemIndex() {
-               return $this->getViewState(self::ITEM_INDEX, 0);
-       }
-
-       public function setItemIndex($item_index) {
-               $this->setViewState(self::ITEM_INDEX, $item_index);
-       }
-
-       public function getItemType() {
-       }
-
-       public function setItemType($item_type) {
+               return $control;
        }
 
        public function getData() {
index d481c68fffcdf44d7db0a4efa2d3ea4933a1d5ab..695702a0421543e5544592c8d6307a2708ed68aa 100644 (file)
@@ -1,4 +1,4 @@
-<div class="w3-row w3-margin-bottom<%=!$this->display_directive ? ' hide' : '';%>">
+<div class="directive_field w3-row w3-margin-bottom<%=!$this->display_directive ? ' hide' : '';%>">
        <div class="w3-col w3-quarter"><com:TActiveLabel ID="Label" ActiveControl.EnableUpdate="false" Visible="<%=$this->display_directive%>" />:</div>
        <div class="w3-col w3-threequarter directive_value">
                <com:TActiveTextBox ID="Directive"
index 0b1a6192ed36e5b3f3a786c514b76fed52061096..e38a7ad66a0bbb1c37b72c19b3235f0d31f580e5 100644 (file)
@@ -1,4 +1,4 @@
-<div class="w3-row w3-margin-bottom<%=!$this->display_directive ? ' hide' : '';%>">
+<div class="directive_field w3-row w3-margin-bottom<%=!$this->display_directive ? ' hide' : '';%>">
        <div class="w3-col w3-quarter"><com:TActiveLabel ID="Label" ActiveControl.EnableUpdate="false" Visible="<%=$this->display_directive%>" />:</div>
        <div class="w3-col w3-threequarter directive_value">
                <com:TActiveTextBox ID="Directive"
index f22621b19dd4efb3a750627561722a689d463950..a7b87cdb6e1117ae429731a89475ce9a333c3541 100644 (file)
@@ -1,4 +1,4 @@
-<div class="w3-row w3-margin-bottom<%=!$this->display_directive ? ' hide' : '';%>">
+<div class="directive_field w3-row w3-margin-bottom<%=!$this->display_directive ? ' hide' : '';%>">
        <div class="w3-col w3-quarter"><com:TActiveLabel ID="Label" ActiveControl.EnableUpdate="false" Visible="<%=$this->display_directive%>" />:</div>
        <div class="w3-col w3-threequarter directive_value">
                <com:TActiveTextBox ID="Directive"
index c4617d7152cf4776c87b36b364c2bbb5bcd3d16c..61c3279d734ae7f6f933be498406d045d92f5cc9 100644 (file)
@@ -1,4 +1,4 @@
-<div class="w3-row w3-margin-bottom<%=!$this->display_directive ? ' hide' : '';%>">
+<div class="directive_field w3-row w3-margin-bottom<%=!$this->display_directive ? ' hide' : '';%>">
        <div class="w3-col w3-quarter"><com:TActiveLabel ID="Label" ActiveControl.EnableUpdate="false" Visible="<%=$this->display_directive%>" />:</div>
        <div class="w3-col w3-threequarter directive_value">
                <com:TActiveTextBox ID="Directive"
index 6cca0951cd536bf03dc997709e61ff979a38b1d5..57a22d7be13f30016cc87b94096a1758769ee54f 100644 (file)
@@ -39,8 +39,8 @@ class FileSetBrowser extends Portlets {
                for ($i = 0; $i < count($clients); $i++) {
                        $client_list[$clients[$i]->clientid] = $clients[$i]->name;
                }
-               asort($client_list);
-               $this->Client->dataSource = $client_list;
+               uksort($client_list, 'sort_client_list');
+               $this->Client->DataSource = $client_list;
                $this->Client->dataBind();
        }
 
@@ -99,4 +99,12 @@ class FileSetBrowser extends Portlets {
                return $this->getViewState(self::PATH, '/');
        }
 }
+
+function sort_client_list($a, $b) {
+       if ($a === 'none') {
+               return -1;
+       } else {
+               return strcmp($a, $b);
+       }
+}
 ?>
index 4fae10dd862548028812e4949888c114ec24e72d..61fe5a42495c28afd4232b1038e8aac661868053 100644 (file)
@@ -1,5 +1,5 @@
 <div class="w3-container">
-       <div class="w3-container">
+       <div class="directive_field w3-container">
                <div class="w3-third"><com:TLabel ForControl="Client" Text="<%[ Client: ]%>" /></div>
                <div class="w3-third">
                        <com:TActiveDropDownList
@@ -76,7 +76,7 @@ var oFileSetBrowser = {
                this.clear_content();
                this.clear_includes();
                this.path_field.value = '';
-               document.getElementById('<%=$this->Client->ClientID%>').value = '';
+               document.getElementById('<%=$this->Client->ClientID%>').value = 'none';
        },
        ls_items: function(path) {
                var dpath;