mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-20 12:58:46 +01:00
WIP on placeholders
- Some TS cleanup - Fix error in preview giving wrong results
This commit is contained in:
parent
8db7d13c49
commit
8e67e2efad
@ -15,7 +15,6 @@
|
|||||||
et2_widget_description;
|
et2_widget_description;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {et2_valueWidget} from "./et2_core_valueWidget";
|
|
||||||
import {et2_createWidget, et2_register_widget, WidgetConfig} from "./et2_core_widget";
|
import {et2_createWidget, et2_register_widget, WidgetConfig} from "./et2_core_widget";
|
||||||
import {ClassWithAttributes} from "./et2_core_inheritance";
|
import {ClassWithAttributes} from "./et2_core_inheritance";
|
||||||
import {et2_dialog} from "./et2_widget_dialog";
|
import {et2_dialog} from "./et2_widget_dialog";
|
||||||
@ -47,6 +46,9 @@ export class et2_placeholder_select extends et2_inputWidget
|
|||||||
dialog : et2_dialog;
|
dialog : et2_dialog;
|
||||||
protected value : any;
|
protected value : any;
|
||||||
|
|
||||||
|
protected LIST_URL = 'EGroupware\\Api\\Etemplate\\Widget\\Placeholder::ajax_get_placeholders';
|
||||||
|
protected TEMPLATE = '/api/templates/default/insert_merge_placeholder.xet?1';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -76,7 +78,7 @@ export class et2_placeholder_select extends et2_inputWidget
|
|||||||
{
|
{
|
||||||
this.egw().loading_prompt('placeholder_select', true, '', 'body');
|
this.egw().loading_prompt('placeholder_select', true, '', 'body');
|
||||||
this.egw().json(
|
this.egw().json(
|
||||||
'EGroupware\\Api\\Etemplate\\Widget\\Placeholder::ajax_get_placeholders',
|
this.LIST_URL,
|
||||||
[],
|
[],
|
||||||
function(_content)
|
function(_content)
|
||||||
{
|
{
|
||||||
@ -93,7 +95,7 @@ export class et2_placeholder_select extends et2_inputWidget
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds file navigator dialog
|
* Builds placeholder selection dialog
|
||||||
*
|
*
|
||||||
* @param {object} _data content
|
* @param {object} _data content
|
||||||
*/
|
*/
|
||||||
@ -161,16 +163,27 @@ export class et2_placeholder_select extends et2_inputWidget
|
|||||||
minHeight: 400,
|
minHeight: 400,
|
||||||
width: 400,
|
width: 400,
|
||||||
value: data,
|
value: data,
|
||||||
template: this.egw().webserverUrl + '/api/templates/default/insert_merge_placeholder.xet?1',
|
template: this.egw().webserverUrl + this.TEMPLATE,
|
||||||
resizable: true
|
resizable: true
|
||||||
}, et2_dialog._create_parent('api'));
|
}, et2_dialog._create_parent('api'));
|
||||||
this.dialog.template.uniqueId = 'api.insert_merge_placeholder';
|
this.dialog.template.uniqueId = 'api.insert_merge_placeholder';
|
||||||
|
|
||||||
|
|
||||||
this.dialog.div.on('load', function(e)
|
this.dialog.div.on('load', this._on_template_load.bind(this));
|
||||||
{
|
}
|
||||||
console.log(this);
|
|
||||||
|
|
||||||
|
doLoadingFinished()
|
||||||
|
{
|
||||||
|
this._content.call(this, null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post-load of the dialog
|
||||||
|
* Bind internal events, set some things that are difficult to do in the template
|
||||||
|
*/
|
||||||
|
_on_template_load()
|
||||||
|
{
|
||||||
let app = <et2_selectbox>this.dialog.template.widgetContainer.getDOMWidgetById("app");
|
let app = <et2_selectbox>this.dialog.template.widgetContainer.getDOMWidgetById("app");
|
||||||
let group = <et2_selectbox>this.dialog.template.widgetContainer.getDOMWidgetById("group");
|
let group = <et2_selectbox>this.dialog.template.widgetContainer.getDOMWidgetById("group");
|
||||||
let placeholder_list = <et2_selectbox>this.dialog.template.widgetContainer.getDOMWidgetById("placeholder_list");
|
let placeholder_list = <et2_selectbox>this.dialog.template.widgetContainer.getDOMWidgetById("placeholder_list");
|
||||||
@ -210,16 +223,13 @@ export class et2_placeholder_select extends et2_inputWidget
|
|||||||
};
|
};
|
||||||
|
|
||||||
this._on_placeholder_select();
|
this._on_placeholder_select();
|
||||||
}.bind(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
doLoadingFinished()
|
/**
|
||||||
{
|
* User has selected a placeholder
|
||||||
this._content.call(this, null);
|
* Update the UI, and if they have an entry selected do the replacement and show that.
|
||||||
return true;
|
*/
|
||||||
}
|
_on_placeholder_select()
|
||||||
|
|
||||||
_on_placeholder_select(node, widget : et2_selectbox | et2_link_entry)
|
|
||||||
{
|
{
|
||||||
let app = <et2_link_entry>this.dialog.template.widgetContainer.getDOMWidgetById("app");
|
let app = <et2_link_entry>this.dialog.template.widgetContainer.getDOMWidgetById("app");
|
||||||
let entry = <et2_link_entry>this.dialog.template.widgetContainer.getDOMWidgetById("entry");
|
let entry = <et2_link_entry>this.dialog.template.widgetContainer.getDOMWidgetById("entry");
|
||||||
@ -251,7 +261,12 @@ export class et2_placeholder_select extends et2_inputWidget
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_get_group_options(appname)
|
/**
|
||||||
|
* Get the list of placeholder groups under the selected application
|
||||||
|
* @param appname
|
||||||
|
* @returns {value:string, label:string}[]
|
||||||
|
*/
|
||||||
|
_get_group_options(appname : string)
|
||||||
{
|
{
|
||||||
let options = [];
|
let options = [];
|
||||||
Object.keys(et2_placeholder_select.placeholders[appname]).map((key) =>
|
Object.keys(et2_placeholder_select.placeholders[appname]).map((key) =>
|
||||||
@ -265,7 +280,14 @@ export class et2_placeholder_select extends et2_inputWidget
|
|||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
_get_placeholders(appname, group)
|
/**
|
||||||
|
* Get a list of placeholders under the given application + group
|
||||||
|
*
|
||||||
|
* @param appname
|
||||||
|
* @param group
|
||||||
|
* @returns {value:string, label:string}[]
|
||||||
|
*/
|
||||||
|
_get_placeholders(appname : string, group : string)
|
||||||
{
|
{
|
||||||
let options = [];
|
let options = [];
|
||||||
Object.keys(et2_placeholder_select.placeholders[appname][group]).map((key) =>
|
Object.keys(et2_placeholder_select.placeholders[appname][group]).map((key) =>
|
||||||
|
@ -99,7 +99,7 @@ class Placeholder extends Etemplate\Widget
|
|||||||
{
|
{
|
||||||
case 'addressbook':
|
case 'addressbook':
|
||||||
default:
|
default:
|
||||||
$merged = $merge->merge_string($content, [$entry['id']], $err, 'text/plain');
|
$merged = $merge->merge_string($content, [$entry], $err, 'text/plain');
|
||||||
}
|
}
|
||||||
$response = Api\Json\Response::get();
|
$response = Api\Json\Response::get();
|
||||||
$response->data($merged);
|
$response->data($merged);
|
||||||
|
Loading…
Reference in New Issue
Block a user