Importsource: some more branch-related hints

This commit is contained in:
Thomas Gelf 2021-12-14 08:36:08 +01:00
parent bfdcafca52
commit 68cf42490f
2 changed files with 55 additions and 15 deletions

View File

@ -104,8 +104,12 @@ class ImportsourceController extends ActionController
public function addAction() public function addAction()
{ {
$this->addTitle($this->translate('Add import source')) $this->addTitle($this->translate('Add import source'));
->content()->add( if ($this->showNotInBranch($this->translate('Creating Import Sources'))) {
return;
}
$this->content()->add(
ImportSourceForm::load()->setDb($this->db()) ImportSourceForm::load()->setDb($this->db())
->setSuccessUrl('director/importsources') ->setSuccessUrl('director/importsources')
->handleRequest() ->handleRequest()
@ -119,6 +123,9 @@ class ImportsourceController extends ActionController
{ {
$this->addMainActions(); $this->addMainActions();
$this->activateTabWithPostfix($this->translate('Modify')); $this->activateTabWithPostfix($this->translate('Modify'));
if ($this->showNotInBranch($this->translate('Modifying Import Sources'))) {
return;
}
$form = ImportSourceForm::load() $form = ImportSourceForm::load()
->setObject($this->getImportSource()) ->setObject($this->getImportSource())
->setListUrl('director/importsources') ->setListUrl('director/importsources')
@ -138,6 +145,9 @@ class ImportsourceController extends ActionController
{ {
$this->addMainActions(); $this->addMainActions();
$this->activateTabWithPostfix($this->translate('Clone')); $this->activateTabWithPostfix($this->translate('Clone'));
if ($this->showNotInBranch($this->translate('Cloning Import Sources'))) {
return;
}
$source = $this->getImportSource(); $source = $this->getImportSource();
$this->addTitle('Clone: %s', $source->get('source_name')); $this->addTitle('Clone: %s', $source->get('source_name'));
$form = new CloneImportSourceForm($source); $form = new CloneImportSourceForm($source);
@ -220,9 +230,13 @@ class ImportsourceController extends ActionController
protected function requireImportSourceAndAddModifierTable() protected function requireImportSourceAndAddModifierTable()
{ {
$source = $this->getImportSource(); $source = $this->getImportSource();
PropertymodifierTable::load($source, $this->url()) $table = PropertymodifierTable::load($source, $this->url());
->handleSortPriorityActions($this->getRequest(), $this->getResponse()) if ($this->getBranch()->isBranch()) {
->renderTo($this); $table->setReadOnly();
} else {
$table->handleSortPriorityActions($this->getRequest(), $this->getResponse());
}
$table->renderTo($this);
return $source; return $source;
} }
@ -267,6 +281,10 @@ class ImportsourceController extends ActionController
)->addBackToModifiersLink($source); )->addBackToModifiersLink($source);
$this->tabs()->activate('modifier'); $this->tabs()->activate('modifier');
if ($this->showNotInBranch($this->translate('Modifying Import Sources'))) {
return;
}
$this->content()->prepend( $this->content()->prepend(
ImportRowModifierForm::load()->setDb($this->db()) ImportRowModifierForm::load()->setDb($this->db())
->setSource($source) ->setSource($source)
@ -293,6 +311,9 @@ class ImportsourceController extends ActionController
)->addBackToModifiersLink($source); )->addBackToModifiersLink($source);
$source = $this->requireImportSourceAndAddModifierTable(); $source = $this->requireImportSourceAndAddModifierTable();
$this->tabs()->activate('modifier'); $this->tabs()->activate('modifier');
if ($this->showNotInBranch($this->translate('Modifying Import Sources'))) {
return;
}
$listUrl = 'director/importsource/modifier?source_id=' $listUrl = 'director/importsource/modifier?source_id='
. (int) $source->get('id'); . (int) $source->get('id');

View File

@ -30,6 +30,8 @@ class PropertymodifierTable extends ZfQueryBasedTable
protected $priorityColumn = 'priority'; protected $priorityColumn = 'priority';
protected $readOnly = false;
public static function load(ImportSource $source, Url $url) public static function load(ImportSource $source, Url $url)
{ {
$table = new static($source->getConnection()); $table = new static($source->getConnection());
@ -38,8 +40,17 @@ class PropertymodifierTable extends ZfQueryBasedTable
return $table; return $table;
} }
public function setReadOnly($readOnly = true)
{
$this->readOnly = $readOnly;
return $this;
}
public function render() public function render()
{ {
if ($this->readOnly) {
return parent::render();
}
return $this->renderWithSortableForm(); return $this->renderWithSortableForm();
} }
@ -82,13 +93,18 @@ class PropertymodifierTable extends ZfQueryBasedTable
$caption .= ': ' . $row->description; $caption .= ': ' . $row->description;
} }
return $this->addSortPriorityButtons( $renderedRow = $this::row([
$this::row([
Link::create($caption, 'director/importsource/editmodifier', [ Link::create($caption, 'director/importsource/editmodifier', [
'id' => $row->id, 'id' => $row->id,
'source_id' => $row->source_id, 'source_id' => $row->source_id,
]), ]),
]), ]);
if ($this->readOnly) {
return $renderedRow;
}
return $this->addSortPriorityButtons(
$renderedRow,
$row $row
); );
} }
@ -109,6 +125,9 @@ class PropertymodifierTable extends ZfQueryBasedTable
public function getColumnsToBeRendered() public function getColumnsToBeRendered()
{ {
if ($this->readOnly) {
return [$this->translate('Property')];
}
return [ return [
$this->translate('Property'), $this->translate('Property'),
$this->getSortPriorityTitle() $this->getSortPriorityTitle()