$this->RepeaterRunscriptOptions->dataBind();
}
- public function getDirectiveValue($allow_empty = false) {
+ public function getDirectiveValue() {
$directive_values = null;
$component_type = $this->getComponentType();
$resource_type = $this->getResourceType();
return $directive_values;
}
+ public function removeRunscript($sender, $param) {
+ if ($param instanceof Prado\Web\UI\TCommandEventParameter) {
+ $idx = $param->getCommandName();
+ $data = $this->getDirectiveValue();
+ if (is_array($data)) {
+ array_splice($data['Runscript'], $idx, 1);
+ $this->setData($data);
+ $this->loadConfig();
+ }
+ }
+ }
+
public function newRunscriptDirective() {
$data = $this->getDirectiveValue(true);
if (is_array($data) && key_exists('Runscript', $data) && is_array($data['Runscript'])) {
}
$this->setData($data);
$this->SourceTemplateControl->setShowAllDirectives(true);
- $this->loadConfig(null, null);
+ $this->loadConfig();
}
}
* Bacula(R) is a registered trademark of Kern Sibbald.
*/
+Prado::using('System.Web.UI.ActiveControls.TActiveLinkButton');
Prado::using('Application.Web.Portlets.DirectiveRenderer');
/**
*/
class JobRunscriptRenderer extends DirectiveRenderer {
- private static $index = 0;
+ const DIRECTIVE_COUNT = 7;
+
+ private static $render_index = 0;
private $item_count;
+ public function onInit($param) {
+ parent::onInit($param);
+ if ($this->ItemIndex % self::DIRECTIVE_COUNT === 0) {
+ $alb = new TActiveLinkButton;
+ $alb->CssClass = 'w3-button w3-green w3-right';
+ $alb->OnCommand = 'SourceTemplateControl.removeRunscript';
+ $alb->CommandName = $this->ItemIndex / self::DIRECTIVE_COUNT;
+ $alb->CommandParameter = 'save';
+ $alb->Text = '<i class="fa fa-trash-alt"></i> ' . Prado::localize('Remove');
+ $this->addParsedObject($alb);
+ }
+ }
+
public function onPreRender($param) {
parent::onPreRender($param);
$this->item_count = $this->getParent()->getItems()->getCount();
}
public function render($writer) {
- if (self::$index % 7 === 0) {
- $writer->write('<h3 class="runscript_options">Runscript #' . ((self::$index/7) + 1) . '</h3><hr />');
+ if (self::$render_index % self::DIRECTIVE_COUNT === 0) {
+ $writer->write('<h3 class="w3-left runscript_options">Runscript #' . ((self::$render_index / self::DIRECTIVE_COUNT) + 1) . '</h3><hr />');
}
- self::$index++;
+ self::$render_index++;
- if (self::$index === $this->item_count) {
- $this->resetIndex();
+ if (self::$render_index === $this->item_count) {
+ $this->resetRenderIndex();
}
parent::render($writer);
}
- public static function resetIndex() {
- self::$index = 0;
+ public static function resetRenderIndex() {
+ self::$render_index = 0;
}
}
?>