Page 1 of 1

Conversion and layout problem

Posted: Wed May 11, 2016 12:58 pm
by vijo
Hi again,

I'm trying to insert some fields into a mobile device layout automatically during conversion of DDS files.
I've put the following code into my conversion theme:

Code: Select all

    
    "process field": function(field, item, isSubfile, isWindow){
        if (!isWindow){
          item.layout = "MainPanel";
          if(field.row <= 2) {
            item.container = "1";
            console.log(item);
            item["css class"] = "top-line";
          } else {

              item.container = "2";
          }
        }
      },
    "process fkey": function(keyword, item, format, member) {
          item.layout = "MainPanel";
          item.container = "3";
          console.log(item);
    },
    
fkeys buttons are OK, they are correctly inserted in the bottom container of the layout but others fields are not.
In the browser console, they seem to be fine:

Code: Select all

Object { id: "constant1", field type: "output field", value: " GESTION DES EMPLOYES ", css class: "ld-constant", left: "240px", cursor column: "30", top: "20px", cursor row: "1", css class 2: "top-line", layout: "MainPanel", container: "1"}
but if i save to a json file here is what i get:

Code: Select all

{ "id": "constant1", "field type": "output field", "value": " GESTION DES EMPLOYES ", "css class": "top-line", "left": "240px", "cursor column": "30", "top": "20px", "cursor row": "1", "css class 2": "top-line" }
I don't understand how these attributes (layout and container) are lost.

Re: Conversion and layout problem

Posted: Wed May 11, 2016 4:33 pm
by David
It could be that the "process field" hook runs before "MainPanel" is rendered. I assume "MainPanel" is added using the theme's "items" array. "process fields" is dealing with items converted from original DDS screen components...

Try using the "add enhancements" hook to do that, does it work? "add enhancements" is a lot more capable. It runs at the end of the process, when the converted record format is complete.

You can use it like this:

Code: Select all

...
"add enhancements": function(format, isSFL, isWin, srcMember, ddsKeywords)  {

  var screenPropsObject = format.screen;
  var widgetsArray = format.items;

}
...
The widgets array should include everything except for Grids, there is a separate "grid enhancements" hook for those.

Re: Conversion and layout problem

Posted: Thu May 12, 2016 5:01 am
by vijo
Thanks David,

Code: Select all

I assume "MainPanel" is added using the theme's "items" array. "process fields"
Actually it was added via the add enhancemt hook. Now, adding it using "items" array, this function does the trick:

Code: Select all

  "process field": function(field, item, isSubfile, isWindow){
      var panelId = field.memberName + '_' + field.formatName + '_MainPanel';
      if (!isWindow && !isSubfile){
        if(field.row <= 2){
          item.layout = panelId;
          item.container = '1';
          item["css class"] = "top-line";
        } else {
            item.layout = panelId;
            item.container = '2';
        }
      }
    },