Merge branch release/21.7.6 of zentao/zentaopms (#11813)
This commit is contained in:
@@ -2441,4 +2441,18 @@ window.onDocAppModeChange = function()
|
||||
{
|
||||
lastDisconnectMessager && lastDisconnectMessager.hide();
|
||||
lastDisconnectMessager = null;
|
||||
}
|
||||
};
|
||||
|
||||
window.getPageFormHelper = function()
|
||||
{
|
||||
const docApp = getDocApp();
|
||||
if(docApp.mode === 'edit' && !isApiDoc(docApp.doc))
|
||||
{
|
||||
const fields =
|
||||
{
|
||||
title: (_, $scope) => $scope.find('.doc-editor-title'),
|
||||
content: (_, $scope) => $scope.find('[z-use-editor]'),
|
||||
};
|
||||
return zui.formHelper($(docApp.element).find('.doc-editor'), {fields: fields});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -52,7 +52,8 @@ class StepsEditor extends zui.Component
|
||||
{
|
||||
this.render();
|
||||
const $element = this.$element;
|
||||
$element.on('focus', 'textarea', e =>
|
||||
$element.attr('zui-form-field', this.options.name)
|
||||
.on('focus', 'textarea', e =>
|
||||
{
|
||||
const $textarea = $(e.target);
|
||||
$textarea.closest('.steps-editor-col-step').addClass('focus');
|
||||
@@ -410,13 +411,18 @@ class StepsEditor extends zui.Component
|
||||
|
||||
moveBefore(fromName, toName)
|
||||
{
|
||||
if(fromName === toName) return;
|
||||
|
||||
const item = this.getByName(fromName);
|
||||
const toItem = this.getByName(toName);
|
||||
if(!item || !toItem) return;
|
||||
item.name = toItem.level > 1 ? `${toItem.parentName}.${+toItem.selfName - 1}` : `${+toItem.selfName - 1}`;
|
||||
this.updateItem(item);
|
||||
}
|
||||
|
||||
getData()
|
||||
{
|
||||
return this._items;
|
||||
}
|
||||
}
|
||||
|
||||
/* Define $.fn.stepsEditor() helper. */
|
||||
@@ -424,3 +430,24 @@ StepsEditor.register();
|
||||
|
||||
/* Extend StepsEditor to zui object. */
|
||||
$.extend(zui, {StepsEditor});
|
||||
|
||||
/* Register stepsEditor to zui.FormHelper. */
|
||||
zui.FormHelper.registerControl('stepsEditor', ($field, $scope) =>
|
||||
{
|
||||
const $stepsEditor = $field.closest('[z-use-stepseditor]');
|
||||
if (!$stepsEditor.length || !$stepsEditor.closest($scope).length) {
|
||||
return;
|
||||
}
|
||||
const instance = $stepsEditor.zui('StepsEditor');
|
||||
return {
|
||||
type: 'stepsEditor',
|
||||
$element: $stepsEditor,
|
||||
instance: instance,
|
||||
getVal: () => instance.getData(),
|
||||
setVal: (value) => {
|
||||
if(!Array.isArray(value)) return;
|
||||
instance.reset(value.map((x, idx) => ({name: String(idx + 1), step: x.step || x.steps, expect: x.expect || x.expects})));
|
||||
return true;
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
@@ -71,6 +71,7 @@ $config->ai->dtable->miniPrograms['publishedLabel']['required'] = true;
|
||||
$config->ai->dtable->miniPrograms['category']['title'] = $lang->prompt->module;
|
||||
$config->ai->dtable->miniPrograms['category']['required'] = true;
|
||||
$config->ai->dtable->miniPrograms['category']['map'] = $lang->ai->miniPrograms->categoryList;
|
||||
$config->ai->dtable->miniPrograms['category']['hint'] = true;
|
||||
|
||||
$config->ai->dtable->miniPrograms['createdByLabel']['title'] = $lang->prompt->createdBy;
|
||||
$config->ai->dtable->miniPrograms['createdByLabel']['required'] = true;
|
||||
|
||||
+2
-2
@@ -58,7 +58,7 @@ window.executeZentaoPrompt = async function(info, auto)
|
||||
const toolName = `zentao_tool_${info.promptID}`;
|
||||
const dataPropNames = info.dataPropNames || {};
|
||||
let propNames = dataPropNames[info.objectType] || {};
|
||||
const isChange = info.schema.title === dataPropNames.title;
|
||||
const isChange = info.schema.title === dataPropNames.common;
|
||||
if(!isChange)
|
||||
{
|
||||
const properties = info.schema.properties;
|
||||
@@ -90,7 +90,7 @@ window.executeZentaoPrompt = async function(info, auto)
|
||||
let diffView = null;
|
||||
const explainView = response.explain ? h`<div><i class="icon icon-lightbulb text-gray"></i> ${response.explain}</div>` : null;
|
||||
const renderValue = value => (typeof value === 'object') ? JSON.stringify(value, 2) : value;
|
||||
if(!isChange && originObject)
|
||||
if(isChange && originObject)
|
||||
{
|
||||
const renderProp = (prop, value) => {
|
||||
let oldValue = originObject[prop];
|
||||
|
||||
+9
-3
@@ -221,7 +221,7 @@
|
||||
if(window.onPageUnmount) window.onPageUnmount();
|
||||
$(document).trigger('pageunmount.app');
|
||||
|
||||
['beforePageLoad', 'beforeRequestContent', 'onPageUnmount', 'beforePageUpdate', 'afterPageUpdate', 'onPageRender', 'afterPageRender'].forEach(key =>
|
||||
['beforePageLoad', 'beforeRequestContent', 'onPageUnmount', 'beforePageUpdate', 'afterPageUpdate', 'onPageRender', 'afterPageRender', 'getPageFormHelper'].forEach(key =>
|
||||
{
|
||||
if(window[key]) delete window[key];
|
||||
});
|
||||
@@ -1403,8 +1403,14 @@
|
||||
|
||||
function applyFormData(data, formSelector)
|
||||
{
|
||||
const $form = $(formSelector || '#mainContainer form');
|
||||
const formHelper = zui.formHelper($form);
|
||||
let formHelper;
|
||||
if(window.getPageFormHelper) formHelper = window.getPageFormHelper(formSelector, data);
|
||||
if(!formHelper)
|
||||
{
|
||||
const $form = $(formSelector || '#mainContainer form');
|
||||
formHelper = zui.formHelper($form);
|
||||
}
|
||||
|
||||
formHelper.setFormData(data);
|
||||
}
|
||||
|
||||
|
||||
+28
-28
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user