newForm method

dynamic newForm(
  1. dynamic data,
  2. dynamic context
)

Implementation

newForm(data, context) {
  myLogAll('newForm');
  //if data[gLabel] == gAdvanceSearch
  var tableName = data[gActionid] ?? data[gTableID];
  //dynamic formDefine = _formLists[tableName];
  var dataLabel = data[gLabel] ?? '';
  dynamic formDefine = getForm(tableName, dataLabel, context);
  Map<dynamic, dynamic> items = formDefine[gItems];
  Map mapWhereList = {};
  if (data[gData] != null) {
    Map mapData = getMap(data[gData]);
    if (!isNull(mapData[gWhere])) {
      List whereList = mapData[gWhere].split(" and ");
      for (int i = 0; i < whereList.length; i++) {
        dynamic element = whereList[i];
        if (element.indexOf("=") > 0) {
          String aKey = element.substring(0, element.indexOf("="));
          String aValue = element.substring(element.indexOf("=") + 1);
          if (aValue.indexOf("'") == 0) {
            aValue = aValue.substring(1, aValue.length - 1);
          }
          mapWhereList[aKey] = aValue;
        }
      }
    }
  }
  for (int i = 0; i < items.entries.length; i++) {
    Map item = items.entries.elementAt(i).value;
    if (mapWhereList.containsKey(item[gId])) {
      if (isNull(item[gDefaultValue])) {
        item[gDefaultValue] = mapWhereList[item[gId]];
      }
    }
    item[gValue] = item[gDefaultValue];
    setValue(tableName, item[gId], null, item[gValue], context);
  }
  clearMFocusNode(context);
  setFocusOne(tableName, null, null, true, context, -1);
}