Alpha DevCon 2018
Results 1 to 4 of 4

Thread: Configure Editor Settings when editing an arbitrary value

  1. #1
    Member
    Real Name
    Jason Martin
    Join Date
    Jan 2014
    Location
    Australia
    Posts
    14

    Default Configure Editor Settings when editing an arbitrary value

    The editor configuration settings are generally set in the formview builder including:
    • Help text in editor
    • Field title in editor
    • User defined editor and template settings
    • Editor configuration genie


    However when launching an editor to edit an arbitrary value (not a form view field), how can the required settings be passed?

    The function to launch the editor for editing an arbitrary value is documented and includes a settings object but I can't find any documentation on how the additional editor configuration settings can be passed using the settings object.

    {dialog.object}.editorFromValue(UXEditorSet,valueToEdit,settingsObject);

    https://www.alphasoftware.com/docume...e%20Method.xml

    Does anyone know of a reference to the structure of the settings objects or how to define these settings for editing an arbitrary value?

  2. #2
    Member
    Real Name
    Jason Martin
    Join Date
    Jan 2014
    Location
    Australia
    Posts
    14

    Default Re: Configure Editor Settings when editing an arbitrary value

    I've solved my own mystery by picking up on some clues in the code from the standard editors plus a bit of debugging but I'll leave the post here as a reference for others that may stumble on this.

    A standard call to open an editor to edit an arbitrary value, passing the standard configuration options (Title and Help Text) as well as user defined values and Genie Settings (this example is the Genie Settings for the Numeric Keypad) is shown below. The standard configuration terms used are title, helpText and __genieSettings. User defined editor and template settings are just added at the top of the JSON settings object.

    Code:
    var valueToEdit = '';
    var settings = {
    	commit: function(value,settings) { 
    		console.log("Editor Returned value "+value);
    	},
    	title: "Test Title",
    	helpText: "Some Help Text",
    	aUserDefinedSetting: "Some custom value",
    	anotherUserSetting: {
    		sky: "Blue",
    		water: "Aqua" 
    	},
    	__genieSettings: {
    		size: 3,
    		align: 'left',
    		scale: true,
    		keypad: 'a',
    		customKeys: {
    			allow: false,
    			primary: {allow: true, value: ['*'], html: '*'},
    			secondary: {allow: true, value: ['/'], html: '/'}
    		},
    		negative: {
    			allow: false
    		},
    		decimal: {
    			allow: false,
    			char: '.',
    			places: -1
    		}
    	}
    }
    {dialog.object}.editorFromValue('EDITORSET_1','EDITOR_1',valueToEdit,settings);
    Note that the manner in which these values are processed is controlled by the code in the respective editor. In particular, the title is not currently displayed by default in the standard textbox editor because the code only sets the title if settings.formView is defined which is false when editing an arbitrary value though this was a quick fix to change that behavior to support both.

    Hope this helps someone.

  3. #3
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    6,475

    Default Re: Configure Editor Settings when editing an arbitrary value

    Nice sleuthing Jason. I was just about to post my findings on this... and saw you've figured it out. I'll post anyway... since I've gone through the process.

    The doc, both inline and online for .editorFromValue() are wrong... nasty error too. commit is a property of settings... so it's not commit = but rather commit: Makes you wonder if the code posted for documentation is ever actually tested.

    The Show Editor property of the Editor in use needs to be changed a bit. It starts with this statement...

    Code:
    if(typeof settings.formView != 'undefined')
    and since the editor is not being called from the formView none of its title and help text code will be run. So, comment out the opening if statement and it's ending... and the code will now run for both the .editorFromValue method and the formView control.

  4. #4
    Member
    Real Name
    Jason Martin
    Join Date
    Jan 2014
    Location
    Australia
    Posts
    14

    Default Re: Configure Editor Settings when editing an arbitrary value

    Thanks David

    I didn't mention the errors in the documentation as I had already emailed the corrections to Alpha and whilst errors are not uncommon in Alpha documentation, I have never found a company more responsive to correcting any bugs and issues reported.

    The equals instead of colon was not the only error. The documentation is missing the second parameter (though the example code included the second parameter) however I would be surprised if these errors/omissions are not fixed very quickly. I have also suggested adding more documentation about the settings object in this function.

    I will also email Alpha with a suggestion to tweak the standard code in the editors to support both methods of launching. It's only a single line that needs to be inside that IF block, then the rest of the code executes as expected for either method of launching the editor.

    Code:
    var title = settings['title'];
    if(typeof settings.formView != 'undefined') { 	
    	if(typeof title == 'undefined' || title == '' ) title = settings.formView.active.name;
    }
    if(typeof title == 'undefined') title = '';

Similar Threads

  1. Replies: 2
    Last Post: 04-19-2017, 09:36 AM
  2. can you configure the A5 html editor formatting options?
    By brad.lindsay69@gmail.com in forum Mobile & Browser Applications
    Replies: 4
    Last Post: 08-04-2015, 06:05 AM
  3. Can the HTML editor be limited in it's editing feature set?
    By Fulltimer in forum Application Server Version 11 - Web/Browser Applications
    Replies: 9
    Last Post: 03-27-2013, 06:35 PM
  4. Editing settings on WAS when running as service
    By eskimoavenue in forum Application Server Version 10 - Web/Browser Applications
    Replies: 2
    Last Post: 09-22-2011, 12:27 PM
  5. Style Editor - Position Settings
    By steinmanal in forum Application Server Version 8
    Replies: 2
    Last Post: 11-19-2007, 09:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •