* Code for edit product ui page.
This commit is contained in:
@@ -2,15 +2,15 @@
|
||||
global $app;
|
||||
$config->product->form = new stdclass();
|
||||
$config->product->form->create = array();
|
||||
$config->product->form->create['program'] = array('type' => 'int', 'control' => 'select', 'required' => false, 'default' => 0, 'options' => array());
|
||||
$config->product->form->create['line'] = array('type' => 'int', 'control' => 'select', 'required' => false, 'default' => 0, 'options' => array());
|
||||
$config->product->form->create['name'] = array('type' => 'string', 'control' => 'text', 'required' => true, 'default' => '', 'filter' => 'trim');
|
||||
$config->product->form->create['code'] = array('type' => 'string', 'control' => 'text', 'required' => true, 'default' => '', 'filter' => 'trim');
|
||||
$config->product->form->create['PO'] = array('type' => 'account', 'control' => 'select', 'required' => false, 'default' => '', 'options' => array());
|
||||
$config->product->form->create['QD'] = array('type' => 'account', 'control' => 'select', 'required' => false, 'default' => '', 'options' => array());
|
||||
$config->product->form->create['RD'] = array('type' => 'account', 'control' => 'select', 'required' => false, 'default' => '', 'options' => array());
|
||||
$config->product->form->create['reviewer'] = array('type' => 'array', 'control' => 'multi-select', 'required' => false, 'default' => '', 'filter' => 'join', 'options' => 'users');
|
||||
$config->product->form->create['type'] = array('type' => 'string', 'control' => 'select', 'required' => false, 'default' => 'normal', 'options' => $lang->product->typeList);
|
||||
$config->product->form->create['program'] = array('type' => 'int', 'control' => 'select', 'required' => false, 'default' => 0, 'options' => array());
|
||||
$config->product->form->create['line'] = array('type' => 'int', 'control' => 'select', 'required' => false, 'default' => 0, 'options' => array());
|
||||
$config->product->form->create['name'] = array('type' => 'string', 'control' => 'text', 'required' => true, 'filter' => 'trim');
|
||||
$config->product->form->create['code'] = array('type' => 'string', 'control' => 'text', 'required' => true, 'filter' => 'trim');
|
||||
$config->product->form->create['PO'] = array('type' => 'account', 'control' => 'select', 'required' => false, 'default' => '', 'options' => array());
|
||||
$config->product->form->create['QD'] = array('type' => 'account', 'control' => 'select', 'required' => false, 'default' => '', 'options' => array());
|
||||
$config->product->form->create['RD'] = array('type' => 'account', 'control' => 'select', 'required' => false, 'default' => '', 'options' => array());
|
||||
$config->product->form->create['reviewer'] = array('type' => 'array', 'control' => 'multi-select', 'required' => false, 'default' => '', 'filter' => 'join', 'options' => 'users');
|
||||
$config->product->form->create['type'] = array('type' => 'string', 'control' => 'select', 'required' => false, 'default' => 'normal', 'options' => $lang->product->typeList);
|
||||
$config->product->form->create['status'] = array('type' => 'string', 'control' => 'hidden', 'required' => false, 'default' => 'normal');
|
||||
$config->product->form->create['desc'] = array('type' => 'string', 'control' => 'editor', 'required' => false, 'default' => '', 'width' => 'full');
|
||||
$config->product->form->create['acl'] = array('type' => 'string', 'control' => 'radio', 'required' => false, 'default' => 'private', 'width' => 'full', 'options' => $lang->product->aclList);
|
||||
@@ -21,10 +21,10 @@ $config->product->form->create['createdVersion'] = array('type' => 'string', 'c
|
||||
if($config->systemMode != 'ALM') unset($config->product->form->create['program'], $config->product->form->create['line']);
|
||||
|
||||
$config->product->form->edit = array();
|
||||
$config->product->form->edit['program'] = array('type' => 'int', 'control' => 'select', 'required' => false, 'default' => 0, 'options' => array());
|
||||
$config->product->form->edit['line'] = array('type' => 'int', 'control' => 'select', 'required' => false, 'default' => 0, 'options' => array());
|
||||
$config->product->form->edit['name'] = array('type' => 'string', 'control' => 'text', 'required' => true, 'default' => '', 'filter' => 'trim');
|
||||
$config->product->form->edit['code'] = array('type' => 'string', 'control' => 'text', 'required' => true, 'default' => '', 'filter' => 'trim');
|
||||
$config->product->form->edit['program'] = array('type' => 'int', 'control' => 'select', 'required' => false, 'default' => 0, 'options' => array());
|
||||
$config->product->form->edit['line'] = array('type' => 'int', 'control' => 'select', 'required' => false, 'default' => 0, 'options' => array());
|
||||
$config->product->form->edit['name'] = array('type' => 'string', 'control' => 'text', 'required' => true, 'filter' => 'trim');
|
||||
$config->product->form->edit['code'] = array('type' => 'string', 'control' => 'text', 'required' => true, 'filter' => 'trim');
|
||||
$config->product->form->edit['PO'] = array('type' => 'account', 'control' => 'select', 'required' => false, 'default' => '', 'options' => array());
|
||||
$config->product->form->edit['QD'] = array('type' => 'account', 'control' => 'select', 'required' => false, 'default' => '', 'options' => array());
|
||||
$config->product->form->edit['RD'] = array('type' => 'account', 'control' => 'select', 'required' => false, 'default' => '', 'options' => array());
|
||||
@@ -38,7 +38,7 @@ if($config->systemMode != 'ALM') unset($config->product->form->edit['program'],
|
||||
|
||||
$config->product->form->batchEdit = array();
|
||||
$config->product->form->batchEdit['program'] = array('type' => 'array', 'control' => 'select', 'required' => false, 'default' => 0, 'options' => array());
|
||||
$config->product->form->batchEdit['name'] = array('type' => 'array', 'control' => 'text', 'required' => true, 'default' => '');
|
||||
$config->product->form->batchEdit['name'] = array('type' => 'array', 'control' => 'text', 'required' => true);
|
||||
$config->product->form->batchEdit['line'] = array('type' => 'array', 'control' => 'select', 'required' => false, 'default' => 0, 'options' => array());
|
||||
$config->product->form->batchEdit['PO'] = array('type' => 'array', 'control' => 'select', 'required' => false, 'default' => '', 'options' => array());
|
||||
$config->product->form->batchEdit['QD'] = array('type' => 'array', 'control' => 'select', 'required' => false, 'default' => '', 'options' => array());
|
||||
|
||||
@@ -246,7 +246,13 @@ class product extends control
|
||||
}
|
||||
|
||||
$this->productZen->setCreateMenu($programID);
|
||||
$this->productZen->buildCreateForm($programID, $extra);
|
||||
|
||||
$this->view->title = $this->lang->product->create;
|
||||
$this->view->gobackLink = $this->productZen->getBackLink4Create($extra);
|
||||
$this->view->programID = $programID;
|
||||
$this->view->fields = $this->productZen->getFormFields4Create($programID);
|
||||
unset($this->lang->product->typeList['']);
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -279,7 +285,12 @@ class product extends control
|
||||
$product = $this->product->getByID($productID);
|
||||
$productID = $this->product->saveVisitState($productID, $this->products);
|
||||
|
||||
$this->productZen->buildEditForm($product);
|
||||
$this->view->title = $this->lang->product->edit . $this->lang->colon . $product->name;
|
||||
$this->view->product = $product;
|
||||
$this->view->fields = $this->productZen->getFormFields4Edit($product);
|
||||
unset($this->lang->product->typeList['']);
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
$(function()
|
||||
{
|
||||
setWhite($('[name=acl]:checked'));
|
||||
toggleLineByProgram();
|
||||
});
|
||||
|
||||
function toggleLineByProgram()
|
||||
{
|
||||
var programID = $('#program').val();
|
||||
$('#lineBox').toggleClass('hidden', programID == 0)
|
||||
}
|
||||
@@ -15,15 +15,15 @@ foreach($fields as $field => $attr)
|
||||
|
||||
$control = array();
|
||||
$control['type'] = $attr['control'];
|
||||
if($control['type'] == 'select') $control['type'] = 'picker';
|
||||
if(!empty($attr['options'])) $control['items'] = $attr['options'];
|
||||
if($attr['control'] == 'select') $control['type'] = 'picker';
|
||||
if($attr['control'] == 'radio') $control['type'] = 'radioList';
|
||||
if(!empty($attr['options'])) $control['items'] = $attr['options'];
|
||||
if($attr['control'] == 'multi-select')
|
||||
{
|
||||
$control['type'] = 'picker';
|
||||
$control['multiple'] = true;
|
||||
$fieldName .= '[]';
|
||||
$fieldName .= '[]';
|
||||
}
|
||||
if($attr['control'] == 'radio') $control['type'] = 'radioList';
|
||||
|
||||
if($field == 'line' and common::hasPriv('product', 'manageLine') and $programID)
|
||||
{
|
||||
|
||||
@@ -1,13 +1,50 @@
|
||||
<?php
|
||||
js::set('programID', $product->program);
|
||||
/**
|
||||
* The edit view of product of ZenTaoPMS.
|
||||
*/
|
||||
namespace zin;
|
||||
|
||||
$form = form();
|
||||
$form->buildForm($fields);
|
||||
$form->buildFormAction();
|
||||
/* zin: Define the form in main content */
|
||||
$formItems = array();
|
||||
foreach($fields as $field => $attr)
|
||||
{
|
||||
if(empty($attr['control'])) continue;
|
||||
|
||||
$content = block();
|
||||
$content->from = $form;
|
||||
$fieldName = zget($attr, 'name', $field);
|
||||
$attr['width'] = zget($attr, 'width', '1/2');
|
||||
|
||||
$page = page('create');
|
||||
$page->right->content = $content;
|
||||
$page->x();
|
||||
$control = array();
|
||||
$control['type'] = $attr['control'];
|
||||
if($attr['control'] == 'select')$control['type'] = 'picker';
|
||||
if($attr['control'] == 'radio') $control['type'] = 'radioList';
|
||||
if(!empty($attr['options'])) $control['items'] = $attr['options'];
|
||||
if($attr['control'] == 'multi-select')
|
||||
{
|
||||
$control['type'] = 'picker';
|
||||
$control['multiple'] = true;
|
||||
$fieldName .= '[]';
|
||||
}
|
||||
|
||||
$formGroup = formGroup
|
||||
(
|
||||
set::width($attr['width']),
|
||||
set::name($fieldName),
|
||||
set::label($attr['title']),
|
||||
set::control($control),
|
||||
set::value($attr['default']),
|
||||
set::required($attr['required'])
|
||||
);
|
||||
|
||||
if($attr['control'] == 'hidden') $formGroup = formRow(set::hidden(true), $formGroup);
|
||||
$formItems[$field] = $formGroup;
|
||||
}
|
||||
|
||||
$formItems['program']->add(on::change('toggleLineByProgram();'));
|
||||
$formItems['acl']->add(on::change('setWhite(e.target);'));
|
||||
$formItems['whitelist'] = formRow(set::id('whitelistBox'), $formItems['whitelist']);
|
||||
$formItems['line'] = formRow(set::id('lineBox'), $formItems['line']);
|
||||
|
||||
formPanel($formItems);
|
||||
|
||||
/* ====== Render page ====== */
|
||||
render();
|
||||
|
||||
+3
-41
@@ -207,7 +207,7 @@ class productZen extends product
|
||||
* @access private
|
||||
* @return string
|
||||
*/
|
||||
private function getBackLink4Create(string $extra): string
|
||||
protected function getBackLink4Create(string $extra): string
|
||||
{
|
||||
$extra = str_replace(array(',', ' '), array('&', ''), $extra);
|
||||
parse_str($extra, $output);
|
||||
@@ -263,7 +263,7 @@ class productZen extends product
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
private function getFormFields4Create(int $programID = 0): array
|
||||
protected function getFormFields4Create(int $programID = 0): array
|
||||
{
|
||||
$fields = $this->setSelectFormOptions($programID, $this->config->product->form->create);
|
||||
$fields['program']['default'] = $programID;
|
||||
@@ -279,7 +279,7 @@ class productZen extends product
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
private function getFormFields4Edit(object $product): array
|
||||
protected function getFormFields4Edit(object $product): array
|
||||
{
|
||||
/* Init fields. */
|
||||
$programID = (int)$product->program;
|
||||
@@ -553,44 +553,6 @@ class productZen extends product
|
||||
return array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => $location);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建创建产品页面数据。
|
||||
* Build form fields for create.
|
||||
*
|
||||
* @param int $programID
|
||||
* @param string $extra
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function buildCreateForm(int $programID = 0, string $extra = '')
|
||||
{
|
||||
$this->view->title = $this->lang->product->create;
|
||||
$this->view->gobackLink = $this->getBackLink4Create($extra);
|
||||
$this->view->programID = $programID;
|
||||
$this->view->fields = $this->getFormFields4Create($programID);
|
||||
|
||||
unset($this->lang->product->typeList['']);
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建编辑产品页面数据。
|
||||
* Build form fields for edit.
|
||||
*
|
||||
* @param object $product
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function buildEditForm(object $product)
|
||||
{
|
||||
$this->view->title = $this->lang->product->edit . $this->lang->colon . $product->name;
|
||||
$this->view->product = $product;
|
||||
$this->view->fields = $this->getFormFields4Edit($product);
|
||||
|
||||
unset($this->lang->product->typeList['']);
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建批量编辑产品页面数据。
|
||||
* Build form for batch edit page
|
||||
|
||||
Reference in New Issue
Block a user