Add documentation tab when deleting custom application type

This commit is contained in:
nathangray 2019-05-22 09:35:01 -06:00
parent 255a1bed1e
commit 34efaaa274
3 changed files with 83 additions and 1 deletions

View File

@ -284,6 +284,21 @@ class admin_customfields
$this->tmpl->exec($exec,$content,$sel_options,$readonlys,$preserve);
}
/**
* Delete a type over ajax. Used when Policy is involved, otherwise
* things go normally
*
* @param Array $content
*/
public function ajax_delete_type($content)
{
// Read fields
$this->appname = $content['appname'];
$this->fields = Api\Storage\Customfields::get($content['appname'],true);
$this->content_types = Api\Config::get_content_types($content['appname']);
$this->delete_content_type($content);
}
/**
* Check selectbox values to match regular expression in et2_widget_selectbox.js: _is_multiple_regexp
*
@ -552,8 +567,12 @@ class admin_customfields
function delete_content_type(&$content)
{
$old = array('types' => $this->content_types);
unset($this->content_types[$content['content_types']['types']]);
unset($this->status[$content['content_types']['types']]);
$cmd = new admin_cmd_config($this->appname,array('types' => $this->content_types), $old, $content['admin_cmd']);
$cmd->run();
// save changes to repository
$this->save_repository();
}

View File

@ -961,6 +961,69 @@ app.classes.admin = AppJS.extend(
jQuery(root.getWidgetById('cf_values').getParentDOMNode()).toggle(attributes.cf_values && true);
},
/**
* Change handler for when you delete a custom app type
* If Policy app is available, it asks for documentation
*/
cf_type_delete: function(e, widget) {
var callback = function(button, value) {
if(button === et2_dialog.YES_BUTTON)
{
var values = jQuery.extend(
{},
this.getInstanceManager().getValues(this.getRoot()),
value,
{appname: this.getRoot().getArrayMgr('content').getEntry('content_types[appname]')}
);
egw.json('admin.admin_customfields.ajax_delete_type', [values]).sendRequest();
// Immediately remove the type
var types = this.getRoot().getWidgetById('types');
var options = types.options.select_options;
var key;
for(key in options)
{
if(options.hasOwnProperty(key) && key === types.getValue())
{
delete options[key];
break;
}
}
types.set_select_options(options);
this.egw().message('');
// Trigger load of status for existing type
types.set_value(Object.keys(options)[0]);
}
}.bind(widget);
if(egw.app('policy'))
{
egw.includeJS(egw.link('/policy/js/app.js'), function() {
if(typeof app.policy === 'undefined' || typeof app.policy.confirm === 'undefined')
{
app.policy = new app.classes.policy();
}
var parent = et2_dialog._create_parent(widget.egw());
var dialog = et2_createWidget("dialog", {
callback: callback,
template: egw.link('/policy/templates/default/admin_cmd_narrow.xet'),
title: egw.lang('Delete'),
buttons: et2_dialog.BUTTONS_YES_NO,
value: {content:{}},
width: 'auto'
}, parent);
dialog.egw().message("Entries with a deleted type can cause problems.\nCheck for entries with this type before deleting.", 'warning');
});
}
else
{
callback(et2_dialog.OK_BUTTON);
}
return false;
},
/**
* Activate none standard SMTP mail accounts for selected users
*

View File

@ -22,7 +22,7 @@
<menulist>
<menupopup id="types" no_lang="1" onchange="1"/>
</menulist>
<button label="Delete" id="delete" onclick="et2_dialog.confirm(widget,'Entries with a deleted type can cause problems.\nCheck for entries with this type before deleting.\nDelete?','Delete');"/>
<button label="Delete" id="delete" onclick="app.admin.cf_type_delete"/>
<textbox blur="new name" id="name"/>
<button label="Create" id="create"/>
</row>