prop(array('index', 'tables', 'value', 'onChange', 'tableError')); $value = $value['table']; return sqlBuilderPicker ( set::name("table_$index"), set::label($lang->bi->do), set::items($items), set::value($value), set::placeholder($lang->bi->selectTableTip), set::width('48'), set::labelWidth('30px'), set::onChange($onChange), set::error($error) ); } protected function buildField() { global $lang; list($index, $items, $value, $onChange, $error) = $this->prop(array('index', 'fields', 'value', 'onChange', 'fieldError')); $value = $value['field']; return sqlBuilderPicker ( set::name("field_$index"), set::items($items), set::value($value), set::placeholder($lang->bi->selectFieldTip), set::width('40'), set::onChange($onChange), set::error($error) ); } protected function buildFunction() { global $lang; list($index, $value, $onChange, $error) = $this->prop(array('index', 'value', 'onChange', 'functionError')); $value = $value['function']; return sqlBuilderPicker ( set::name("function_$index"), set::label($lang->bi->set), set::items($lang->bi->funcList), set::value($value), set::placeholder($lang->bi->selectFuncTip), set::onChange($onChange), set::error($error) ); } protected function buildAlias() { global $lang; list($index, $value, $onChange, $emptyError, $duplicateError) = $this->prop(array('index', 'value', 'onChange', 'aliasError', 'duplicateError')); $value = $value['alias']; $errorText = $duplicateError ? $lang->bi->duplicateError : null; return sqlBuilderInput ( set::name("alias_$index"), set::label($lang->bi->funcAs), set::value($value), set::placeholder($lang->bi->selectInputTip), set::width('80'), set::labelWidth('160px'), set::onChange($onChange), set::error($emptyError || $duplicateError), set::errorText($errorText) ); } protected function build() { list($index, $onAdd, $onRemove) = $this->prop(array('index', 'onAdd', 'onRemove')); return formRow ( setClass('mb-4'), $this->buildTable(), $this->buildField(), $this->buildFunction(), $this->buildAlias(), formGroup ( btn ( setClass('add-function'), set('data-index', $index), set::type('ghost'), set::icon('plus'), on::click()->do($onAdd) ), btn ( setClass('remove-function'), set('data-index', $index), set::type('ghost'), set::icon('minus'), on::click()->do($onRemove) ) ) ); } }