1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-18 01:38:39 +01:00
phorge-phorge/src/applications/transactions/editor/PhabricatorEditEngineConfigurationEditEngine.php
epriestley 9aee90f8c1 Allow form configurations to retitle and reorder forms and add preambles
Summary:
Ref T9132. This just makes edited forms do //something//, albeit not anything very useful yet.

You can now edit a form and:

  - Retitle it;
  - add a preamble (instructions on top of the form); and
  - reorder the form's fields.

Test Plan:
{F974632}

{F974633}

{F974634}

{F974635}

{F974636}

Reviewers: chad

Reviewed By: chad

Subscribers: hach-que

Maniphest Tasks: T9132

Differential Revision: https://secure.phabricator.com/D14503
2015-11-22 15:12:57 -08:00

90 lines
2.4 KiB
PHP

<?php
final class PhabricatorEditEngineConfigurationEditEngine
extends PhabricatorEditEngine {
const ENGINECONST = 'transactions.editengine.config';
private $targetEngine;
public function setTargetEngine(PhabricatorEditEngine $target_engine) {
$this->targetEngine = $target_engine;
return $this;
}
public function getTargetEngine() {
return $this->targetEngine;
}
public function getEngineName() {
return pht('Edit Configurations');
}
public function getEngineApplicationClass() {
return 'PhabricatorTransactionsApplication';
}
protected function newEditableObject() {
return PhabricatorEditEngineConfiguration::initializeNewConfiguration(
$this->getViewer(),
$this->getTargetEngine());
}
protected function newObjectQuery() {
return id(new PhabricatorEditEngineConfigurationQuery());
}
protected function getObjectCreateTitleText($object) {
return pht('Create New Form');
}
protected function getObjectEditTitleText($object) {
return pht('Edit Form %d: %s', $object->getID(), $object->getDisplayName());
}
protected function getObjectEditShortText($object) {
return pht('Form %d', $object->getID());
}
protected function getObjectCreateShortText() {
return pht('Create Form');
}
protected function getObjectViewURI($object) {
$id = $object->getID();
return $this->getURI("view/{$id}/");
}
protected function getEditorURI() {
return $this->getURI('edit/');
}
protected function getObjectCreateCancelURI($object) {
return $this->getURI();
}
private function getURI($path = null) {
$engine_key = $this->getTargetEngine()->getEngineKey();
return "/transactions/editengine/{$engine_key}/{$path}";
}
protected function buildCustomEditFields($object) {
return array(
id(new PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setDescription(pht('Name of the form.'))
->setTransactionType(
PhabricatorEditEngineConfigurationTransaction::TYPE_NAME)
->setValue($object->getName()),
id(new PhabricatorRemarkupEditField())
->setKey('preamble')
->setLabel(pht('Preamble'))
->setDescription(pht('Optional instructions, shown above the form.'))
->setTransactionType(
PhabricatorEditEngineConfigurationTransaction::TYPE_PREAMBLE)
->setValue($object->getPreamble()),
);
}
}