Here's what I did:
(1) In the sheet (you probably customized
AppWithinMinutes.LiveTableViewSheet) I added another hidden input
besides the one holding the URL template
{{html}}
<input type="hidden" value="$xwiki.getURL($entryDoc, 'edit',
"editor=inline&template=$!templateName&parent=WebHome")" />
<input type="hidden" name="entryName" value="put here what you want"
#if($condition)readonly="readonly"#end />
{{/html}}
(2) In the JSX I replaced
this.input = new Element('input', {type: 'text'});
with
this.input = trigger.up().next('input[name=entryName]');
this.input.type = 'text';
this.input.defaultValue = this.input.value;
and then
this.input.clear().focus();
with
this.input.value = this.input.defaultValue;
this.input.focus();
This way you control the entry name text input from the Velocity.
Hope this helps,
Marius
On Mon, Jun 11, 2012 at 3:28 PM, Gerritjan Koekkoek
<[email protected]> wrote:
> App Within Minutes creates a nice "Add record" button.
> After clicking the button a dialog is presented asking for input that is
> used to create a new documentname.
>
> This is (more or less, since i modified it slightly) the Java script that
> is added to the sheet by the app-within-minutes generator.
> My question is due to fact that i'm not a javascript expert, so solution
> might be very simple:
> I would like to generate the documentname based on user that is clicking
> the button
> If user in group X then input will be pre populated with 'Full Name" of
> that user and popup will not allow user to change this value;
> Confirmation would be like "New Question will be made for: [[Gerritjan
> Koekkoek]] and user can only proceed or cancel
> If user in group y the same behaviour; but now the inputbox would need to
> be open for change
> Confirmation would be like "New Question will be made for: [[Gerritjan
> Koekkoek]] but now user can change the input to 'Andree Benz' meaning that
> new question is posted by
> Gerritjan Koekkoek on behalf of Andree Benz.
> How would you suggest to change below script to get the desired effect?
> (see lineindicator ==> of what I thought would be a solution?
>
> var XWiki = (function (XWiki) {
>
> XWiki.EntryNamePopup = Class.create(XWiki.widgets.ModalPopup, {
> initialize : function($super, trigger) {
> trigger.observe('click', this.showDialog.bindAsEventListener(this));
> this.urlTemplate = trigger.up().next('input[type=hidden]').value;
>
> this.input = new Element('input', {type: 'text'});
> this.addButton = new Element('input', {type: 'image', src:
> '$xwiki.getSkinFile('icons/silk/add.png')', alt:
> '$escapetool.javascript($msg.get('cdlsateprivat.CreateNewQuestionAltText'))'});
>
> var container = new Element('div', {id: 'entryNamePopup'});
> container.insert(this.input);
> container.insert(this.addButton);
>
> $super(container, {
> show: {method: this.showDialog, keys: []},
> add: {method: this._onAdd, keys: ['Enter']}
> }, {
> title:
> '$escapetool.javascript($msg.get('cdlsateprivat.CreateNewQuestionTitle'))',
> verticalPosition: 'top'
> });
> },
> createDialog : function($super, event) {
> this.input.observe
> this.addButton.observe('click', this._onAdd.bind(this));
> $super(event);
> },
> showDialog : function($super, event) {
> $super(event);
> ==> $this.input.val() == 'Gerritjan Koekkoek' //this line did not work,
> how can I get it prepopulated (or suggested) with preferably XWiki variable
> this.input.clear().focus();
> },
> _onAdd : function() {
> if (this.input.value != '') {
> window.self.location = this.urlTemplate.replace('__entryName__',
> encodeURIComponent(this.input.value));
> } else {
> this.input.focus();
> }
> }
> });
>
> function init() {
> var actionBox = $('actionBox');
> if(actionBox) {
> new XWiki.EntryNamePopup(actionBox.down('.add'));
> return true;
> }
> return false;
> }
> (XWiki.domIsLoaded && init()) || document.observe('xwiki:dom:loaded', init);
>
> return XWiki;
> }(XWiki || {}));
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users