]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Fix using nested directives in repeater control
authorMarcin Haba <marcin.haba@bacula.pl>
Sun, 4 Aug 2019 14:03:27 +0000 (16:03 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Sat, 14 Dec 2019 14:55:28 +0000 (15:55 +0100)
gui/baculum/protected/Web/Portlets/BaculaConfigResources.tpl
gui/baculum/protected/Web/Portlets/DirectiveMessages.php
gui/baculum/protected/Web/Portlets/DirectiveRenderer.php
gui/baculum/protected/Web/Portlets/DirectiveRunscript.php
gui/baculum/protected/Web/Portlets/DirectiveSchedule.php
gui/baculum/protected/Web/Portlets/DirectiveSchedule.tpl
gui/baculum/protected/Web/Portlets/NewScheduleMenu.tpl

index 9b75720dc9efec4a96fa65f4ee397b26218df0a4..00f1a98effccbf8420e62edc9961389b409f8a8e 100644 (file)
@@ -37,7 +37,6 @@
                                                        Attributes.onclick="return BaculaConfig.unset_config_items(this.id);"
                                                        Text="<strong><%=$this->Data['resource_type']%></strong>: <%=$this->Data['resource_name']%>"
                                                        Style="text-decoration: none"
-                                                       CommandParameter="show"
                                                />
                                                        <i class="fa fa-sync w3-spin" style="display: none"><i/>
                                                </td>
index fbacf45435d332291979e65a7bf83a7320f708ae..7d16348770c473efcf5f0b68fb1dcb188a5c74ef 100644 (file)
@@ -64,7 +64,7 @@ class DirectiveMessages extends DirectiveListTemplate {
                'Volmgmt'
        );
 
-       public function loadConfig($sender, $param) {
+       public function loadConfig() {
                $load_values = $this->getLoadValues();
                $destinations = (array)$this->getData();
                if (array_key_exists('Type', $destinations)) {
index 6245a993ec69ad72516fae5adac5e272729ff2e8..b9352fee709dd6a5df8bbca81130aea1c74e12b2 100644 (file)
@@ -66,9 +66,22 @@ class DirectiveRenderer extends DirectiveListTemplate implements IDataRenderer {
 
        public $resource_names = array();
 
+       private $item_loaded = false;
+
        public function onLoad($param) {
                parent::onLoad($param);
-               $this->createItemInternal();
+               if (!$this->item_loaded) {
+                       $this->createItemInternal();
+                       $this->item_loaded = true;
+               }
+       }
+
+       public function dataBind() {
+               if (!$this->item_loaded) {
+                       $this->createItemInternal();
+                       $this->item_loaded = true;
+               }
+               parent::dataBind();
        }
 
        public function createItemInternal() {
@@ -76,11 +89,12 @@ class DirectiveRenderer extends DirectiveListTemplate implements IDataRenderer {
                $item = $this->createItem($data);
 
                $this->addParsedObject($item);
+               $cmd = $item->getCmdParam();
 
                if ($item instanceof DirectiveTemplate) {
                        $item->createDirective();
-               } elseif ($item instanceof DirectiveListTemplate) {
-                       $item->loadConfig(null, null);
+               } elseif ($item instanceof DirectiveListTemplate && $cmd === '') {
+                       $item->loadConfig();
                }
        }
 
index 8558a1a9d906fb3d904a4469f8dd1f5dd025c9b8..024e5525783502c51db84a08bca0ae4f2446138d 100644 (file)
@@ -33,7 +33,7 @@ class DirectiveRunscript extends DirectiveListTemplate {
                'DirectiveComboBox'
        );
 
-       public function loadConfig($sender, $param) {
+       public function loadConfig() {
                $load_values = $this->getLoadValues();
                $host = $this->getHost();
                $component_type = $this->getComponentType();
index 531e892debdc2210ab3632c690bcc1948eba25bd..ccc36bb91f6dd66334acbe61e60b93cfadc159f3 100644 (file)
@@ -80,7 +80,7 @@ class DirectiveSchedule extends DirectiveListTemplate {
                'TimeMinHourly'
        );
 
-       public function loadConfig($sender, $param) {
+       public function loadConfig() {
                $load_values = $this->getLoadValues();
                $directives = $this->getData();
                $host = $this->getHost();
index 261b8c9caac8305528e66e26bb6b0c2c29085999..2dbe038238fde5426e0d3d1369b7c8165d3324f5 100644 (file)
@@ -3,7 +3,7 @@
 <com:TActiveRepeater ID="RepeaterScheduleRuns" OnItemDataBound="createRunItem">
        <prop:ItemTemplate>
                <div class="w3-card-4 w3-padding w3-margin-bottom directive runscript">
-                       <h2><%[ Run ]%> #<%=($this->ItemIndex+1)%></h2>
+                       <h2 class="schedule_options"><%[ Run ]%> #<%=($this->ItemIndex+1)%></h2>
                        <com:Application.Web.Portlets.DirectiveComboBox
                                ID="Level"
                        />
index 14d8ba77abd4586760297fe853b5d3599dc38cdc..1b3ffa7855956e1b35fbd91ad2dfac6271ffc980 100644 (file)
@@ -5,7 +5,7 @@
                        ID="RunscriptItem"
                        OnCommand="Parent.SourceTemplateControl.newScheduleDirective"
                        CommandParameter="save"
-                       ClientSide.OnComplete="var el = $('#<%=$this->RunscriptItem->ClientID%>').parents('div').find('h2'); BaculaConfig.scroll_to_element(el[el.length-1]);"
+                       ClientSide.OnComplete="var el = $('#<%=$this->RunscriptItem->ClientID%>').parents('div').find('h2.schedule_options'); BaculaConfig.scroll_to_element(el[el.length-1], -100);"
                        Text="Run"
                        Attributes.onclick="$(this).closest('div.config_new_schedule').hide();"
                        />