* add default prompt and fields when create program.
This commit is contained in:
@@ -399,7 +399,6 @@ class ai extends control
|
||||
return $this->sendSuccess(array('message' => $this->lang->saveSuccess, 'locate' => $this->createLink('ai', 'editMiniProgram', "appID=$appID")));
|
||||
}
|
||||
|
||||
|
||||
$this->view->iconName = 'writinghand';
|
||||
$this->view->iconTheme = 7;
|
||||
$this->view->categoryList = $this->ai->getCustomCategories();
|
||||
|
||||
@@ -617,19 +617,6 @@ $(function ()
|
||||
updateButtonStatus();
|
||||
});
|
||||
|
||||
if(!currentPrompt)
|
||||
{
|
||||
currentFields = defaultFields;
|
||||
currentPrompt = currentFields.pop();
|
||||
currentFields = currentFields.map(name =>
|
||||
({
|
||||
name,
|
||||
required: '0',
|
||||
type: 'text',
|
||||
placeholder: '',
|
||||
}));
|
||||
}
|
||||
|
||||
currentFields.forEach(field =>
|
||||
{
|
||||
const formData = new FormData();
|
||||
|
||||
+19
-1
@@ -829,6 +829,8 @@ class aiModel extends model
|
||||
$data->published = '0';
|
||||
$data->createdBy = $this->app->user->account;
|
||||
$data->createdDate = helper::now();
|
||||
$data->prompt = $this->lang->ai->miniPrograms->field->default[3];
|
||||
|
||||
if(!empty($data->iconName) && !empty($data->iconTheme))
|
||||
{
|
||||
$data->icon = $data->iconName . '-' . $data->iconTheme;
|
||||
@@ -839,9 +841,25 @@ class aiModel extends model
|
||||
$this->dao->insert(TABLE_MINIPROGRAM)
|
||||
->data($data)
|
||||
->exec();
|
||||
$appID = $this->dao->lastInsertID();
|
||||
|
||||
$defaultFields = $this->lang->ai->miniPrograms->field->default;
|
||||
for($i = 0; $i < 3; $i++)
|
||||
{
|
||||
$field = new stdClass();
|
||||
$field->appID = $appID;
|
||||
$field->name = $defaultFields[$i];
|
||||
$field->type = 'text';
|
||||
$field->placeholder = $this->lang->ai->miniPrograms->placeholder->input;
|
||||
$field->options = null;
|
||||
$field->required = '0';
|
||||
$this->dao->insert(TABLE_MINIPROGRAMFIELD)
|
||||
->data($field)
|
||||
->exec();
|
||||
}
|
||||
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$appID = $this->dao->lastInsertID();
|
||||
$this->loadModel('action')->create('miniProgram', $appID, 'created');
|
||||
return $appID;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ js::set('publishConfirm', $lang->ai->miniPrograms->publishConfirm);
|
||||
js::set('emptyPrompterTip', $lang->ai->miniPrograms->emptyPrompterTip);
|
||||
js::set('currentFields', $currentFields);
|
||||
js::set('currentPrompt', $currentPrompt);
|
||||
js::set('defaultFields', $lang->ai->miniPrograms->field->default);
|
||||
js::set('promptPlaceholder', $lang->ai->miniPrograms->placeholder->prompt);
|
||||
?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user