@magic-xpa/engine 4.900.0-dev491.7 → 4.1000.0-dev000.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,7 +38,6 @@ var ClientTargetedCommandType;
38
38
  })(ClientTargetedCommandType || (ClientTargetedCommandType = {}));
39
39
 
40
40
  class ConstInterface {
41
- ;
42
41
  }
43
42
  ConstInterface.MG_TAG_CONTEXT = "context";
44
43
  ConstInterface.MG_TAG_ENV = "env";
@@ -1205,7 +1204,8 @@ class MgControl extends MgControlBase {
1205
1204
  if (!isTagProcessed) {
1206
1205
  switch (attribute) {
1207
1206
  case ConstInterface.MG_ATTR_SUBFORM_TASK:
1208
- this._subformTaskId = valueStr;
1207
+ if (valueStr.trim() != "")
1208
+ this._subformTaskId = valueStr;
1209
1209
  break;
1210
1210
  case ConstInterface.MG_ATTR_REFRESHON:
1211
1211
  this.refreshOnString = valueStr.trim();
@@ -4132,9 +4132,10 @@ class Scrambler {
4132
4132
  if (high > (sqrt / 2))
4133
4133
  high = Math.floor(sqrt / 2);
4134
4134
  delta = (Math.random() * (high - low)) + low;
4135
+ delta = Math.floor(delta);
4135
4136
  if (delta === Scrambler.XML_ILLEGAL_RANDOM)
4136
4137
  delta++;
4137
- return Math.floor(delta);
4138
+ return delta;
4138
4139
  }
4139
4140
  static UnScramble(inVal, beginOffSet, endOffSet) {
4140
4141
  if (!Scrambler.ScramblingEnabled) {
@@ -6124,17 +6125,22 @@ class LanguageData {
6124
6125
  if (this._mlsContent.length > 0) {
6125
6126
  let linePairs = 0;
6126
6127
  let srcLine = this._mlsContent + 3;
6128
+ let transLine;
6127
6129
  this._mlsStrings = new Hashtable();
6128
- let linesStr = this._mlsContent.substring(this._mlsContent.length - MLS_EOF_CHARS_TO_READ, 8);
6130
+ let linesStr = this._mlsContent.substr(this._mlsContent.length - MLS_EOF_CHARS_TO_READ, 8);
6129
6131
  linePairs = parseInt(linesStr.toString(), 16);
6130
6132
  let tokens = StrUtil.tokenize(srcLine.toString(), "\n");
6131
- for (let line = 0; line < linePairs * 2; line += 2) {
6132
- if (this._mlsStrings.get_Item(tokens[line].toString()) == null)
6133
- this._mlsStrings.set_Item(tokens[line].toString(), tokens[line + 1].toString());
6133
+ for (let pairNum = 0; pairNum < linePairs * 2; pairNum += 2) {
6134
+ srcLine = tokens[pairNum].substr(0, tokens[pairNum].length - 1);
6135
+ transLine = tokens[pairNum + 1].substr(0, tokens[pairNum + 1].length - 1);
6136
+ if (this._mlsStrings.get_Item(srcLine.toString()) == null)
6137
+ this._mlsStrings.set_Item(srcLine.toString(), transLine);
6134
6138
  }
6135
6139
  }
6136
6140
  }
6137
6141
  else if (this._mlsFileUrl != null) {
6142
+ if (this._mlsFileUrl.startsWith("./"))
6143
+ this._mlsFileUrl = NString.Replace(this._mlsFileUrl, './', './assets/cache/');
6138
6144
  let contentStr = await CommandsProcessorManager.GetContent(this._mlsFileUrl, true);
6139
6145
  let buffer = contentStr;
6140
6146
  if (buffer != null && buffer.length > 0) {
@@ -7893,6 +7899,13 @@ class SelectProgramCommand extends ExecOperCommand {
7893
7899
  }
7894
7900
  }
7895
7901
 
7902
+ class ControlItemsRefreshCommand extends DataviewCommand {
7903
+ constructor() {
7904
+ super();
7905
+ this.Control = null;
7906
+ }
7907
+ }
7908
+
7896
7909
  class CommandFactory {
7897
7910
  static CreateEventCommand(taskTag, magicEvent) {
7898
7911
  let eventCommand = new EventCommand(magicEvent);
@@ -7911,6 +7924,13 @@ class CommandFactory {
7911
7924
  dataviewCommand.TaskTag = taskId;
7912
7925
  return dataviewCommand;
7913
7926
  }
7927
+ static CreateControlItemsRefreshCommand(taskId, control) {
7928
+ let command = new ControlItemsRefreshCommand();
7929
+ command.CommandType = DataViewCommandType.ControlItemsRefresh;
7930
+ command.TaskTag = taskId;
7931
+ command.Control = control;
7932
+ return command;
7933
+ }
7914
7934
  static CreateAddUserRangeDataviewCommand(taskId, userRange) {
7915
7935
  let addUserRangeDataviewCommand = new AddUserRangeDataviewCommand();
7916
7936
  addUserRangeDataviewCommand.TaskTag = taskId;
@@ -9261,8 +9281,8 @@ class Operation {
9261
9281
  if (rtEvnt !== null) {
9262
9282
  this._routeParams = rtEvnt.getRouteParamList();
9263
9283
  if ((await rtEvnt.getArgList().getArg(0).getValue(StorageAttribute.ALPHA, 0)).trim() === this._routerPath &&
9264
- ((rtEvnt.getArgList().getArg(1).skipArg()) ||
9265
- (await rtEvnt.getArgList().getArg(1).getValue(StorageAttribute.ALPHA, 0)).trim() === this._originalRouterOutletName))
9284
+ ((rtEvnt.getArgList().getArg(1).skipArg() && destSubForm === this._task.getForm().DefaultRouterOutlet) ||
9285
+ (!rtEvnt.getArgList().getArg(1).skipArg() && (await rtEvnt.getArgList().getArg(1).getValue(StorageAttribute.ALPHA, 0)).trim() === this._originalRouterOutletName)))
9266
9286
  canRoute = true;
9267
9287
  if (!canRoute)
9268
9288
  return false;
@@ -10125,7 +10145,7 @@ class CookieService {
10125
10145
  var cookie = cookies[i];
10126
10146
  var eqPos = cookie.indexOf('=');
10127
10147
  var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
10128
- if (cookieName === decodeURI(name)) {
10148
+ if (cookieName === NString.TrimStart(decodeURI(name))) {
10129
10149
  document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT';
10130
10150
  return true;
10131
10151
  }
@@ -10844,6 +10864,11 @@ class ExpressionEvaluator extends GuiExpressionEvaluator {
10844
10864
  this.eval_op_VarDisplayName(resVal, val1);
10845
10865
  expStrTracker.resetNullResult();
10846
10866
  break;
10867
+ case ExpressionInterface.EXP_OP_CONTROL_ITEMS_REFRESH:
10868
+ val2 = valStack.pop();
10869
+ val1 = valStack.pop();
10870
+ await this.eval_op_controlItemRefresh(val1, val2, resVal);
10871
+ break;
10847
10872
  case ExpressionInterface.EXP_OP_VARCONTROLID:
10848
10873
  val1 = valStack.pop();
10849
10874
  this.eval_op_VarControlID(resVal, val1);
@@ -12972,6 +12997,23 @@ class ExpressionEvaluator extends GuiExpressionEvaluator {
12972
12997
  resVal.StrVal = fld.VarDisplayName;
12973
12998
  }
12974
12999
  }
13000
+ async eval_op_controlItemRefresh(val1, val2, resVal) {
13001
+ let success = false;
13002
+ let parent = val2.MgNumVal.NUM_2_LONG();
13003
+ resVal.Attr = StorageAttribute.BOOLEAN;
13004
+ if ((parent >= 0 && parent < (this.ExpTask.getTaskDepth(false))) || parent === ExpressionEvaluator.TRIGGER_TASK) {
13005
+ let tsk = super.GetContextTask(parent);
13006
+ if (tsk != null && tsk.getForm() != null) {
13007
+ let control = tsk.getForm().GetCtrl(val1.StrVal);
13008
+ if (control != null && control.isChoiceControl() && control.isDataCtrl()) {
13009
+ let command = CommandFactory.CreateControlItemsRefreshCommand(tsk.getTaskTag(), control);
13010
+ await tsk.DataviewManager.CurrentDataviewManager.Execute(command);
13011
+ success = true;
13012
+ }
13013
+ }
13014
+ }
13015
+ resVal.BoolVal = success;
13016
+ }
12975
13017
  eval_op_VarControlID(resVal, val1) {
12976
13018
  let ret = 0;
12977
13019
  if (val1.MgNumVal !== null) {
@@ -14195,7 +14237,7 @@ class ExpressionEvaluator extends GuiExpressionEvaluator {
14195
14237
  }
14196
14238
  path = args[3];
14197
14239
  domain = args[4];
14198
- resVal.BoolVal = CookieService.setCookie(cookieName, args[0], nativeDt, path, domain, secure, sameSite);
14240
+ resVal.BoolVal = CookieService.setCookie(cookieName, (args[0] != null ? args[0].toString() : ""), nativeDt, path, domain, secure, sameSite);
14199
14241
  }
14200
14242
  eval_op_get_cookie(cookieName, resVal) {
14201
14243
  resVal.StrVal = CookieService.getCookie(cookieName);
@@ -16261,7 +16303,8 @@ class Field extends FieldBase {
16261
16303
  }
16262
16304
  break;
16263
16305
  case ConstInterface.MG_ATTR_CHACHED_FLD_ID:
16264
- this.CacheTableFldIdx = NNumber.Parse(data[1]);
16306
+ if (data[0] != "")
16307
+ this.CacheTableFldIdx = NNumber.Parse(data[1]);
16265
16308
  break;
16266
16309
  case ConstInterface.MG_ATTR_LOCATE:
16267
16310
  this.Locate = new Boundary(this.getTask(), NNumber.Parse(data[1]), NNumber.Parse(data[0]), this.getType(), this.getSize(), this.CacheTableFldIdx);
@@ -19367,7 +19410,11 @@ class MgForm extends MgFormBase {
19367
19410
  this.GetDataview().setTopRecIdxModified(true);
19368
19411
  try {
19369
19412
  this._suffixDone = false;
19370
- await this.setCurrRowByDisplayLine(this.GetDataview().getCurrRecIdx() + size, true, false);
19413
+ let newDisplayLine = this.GetDataview().getCurrRecIdx() + size;
19414
+ if (unit === Constants.MOVE_UNIT_PAGE && this.isLineMode())
19415
+ if (newDisplayLine > this.GetDataview().getSize() - 1)
19416
+ visibleLine -= newDisplayLine - (this.GetDataview().getSize() - 1);
19417
+ await this.setCurrRowByDisplayLine(newDisplayLine, true, false);
19371
19418
  this.GetDataview().setTopRecIdxModified(false);
19372
19419
  await this.RefreshDisplay(Constants.TASK_REFRESH_FORM);
19373
19420
  }
@@ -20442,8 +20489,8 @@ class RemoteTaskService extends TaskServiceBase {
20442
20489
  OwnerTransactionTask = task.DataviewManager.RemoteDataviewManager.Transaction.OwnerTask;
20443
20490
  return OwnerTransactionTask;
20444
20491
  }
20445
- static PreparePropMainDisplay(task) {
20446
- task.ComputeMainDisplay();
20492
+ static async PreparePropMainDisplay(task) {
20493
+ await task.ComputeMainDisplay();
20447
20494
  return task.FormIsLegal() ? ReturnResult.SuccessfulResult : new ReturnResult(MsgInterface.BRKTAB_STR_ERR_FORM);
20448
20495
  }
20449
20496
  }
@@ -20843,15 +20890,18 @@ class RemoteDataviewHeader extends DataviewHeaderBase {
20843
20890
  setAttribute(attribute, valueStr) {
20844
20891
  switch (attribute) {
20845
20892
  case ConstInterface.MG_ATTR_CACHED_TABLE:
20846
- if (TableCacheManager.Instance.TableExists(valueStr))
20847
- this._table = TableCacheManager.Instance.GetTableById(valueStr);
20848
- else {
20849
- this._table = new TableCache(valueStr);
20850
- TableCacheManager.Instance.InsertTable(this._table);
20893
+ if (valueStr != "") {
20894
+ if (TableCacheManager.Instance.TableExists(valueStr))
20895
+ this._table = TableCacheManager.Instance.GetTableById(valueStr);
20896
+ else {
20897
+ this._table = new TableCache(valueStr);
20898
+ TableCacheManager.Instance.InsertTable(this._table);
20899
+ }
20851
20900
  }
20852
20901
  break;
20853
20902
  case ConstInterface.MG_ATTR_IDENT:
20854
- this._table.SetTableIdent(valueStr);
20903
+ if (valueStr != "")
20904
+ this._table.SetTableIdent(valueStr);
20855
20905
  break;
20856
20906
  default:
20857
20907
  super.setAttribute(attribute, valueStr);
@@ -21945,9 +21995,17 @@ class RecomputeTable {
21945
21995
  this.fillData_1(task.DataView, task, parser);
21946
21996
  }
21947
21997
  else
21948
- throw new ApplicationException("in RecomputeTable.fillData() invalid task id: ");
21998
+ parser.setCurrIndex(parser.getXMLdata().indexOf(XMLConstants.TAG_CLOSE, parser.getCurrIndex()) + 1);
21949
21999
  }
21950
22000
  fillData_1(dataView, task, parser) {
22001
+ if (parser.getNextTag() == XMLConstants.MG_TAG_RECOMPUTE) {
22002
+ let currrentIndex = parser.getCurrIndex();
22003
+ let encoded = parser.ReadContentOfCurrentElement().trim();
22004
+ let decoded = Base64.decode(encoded.substr(0, encoded.length).trim());
22005
+ let newXmlData = parser.getXMLdata().replace(encoded.trim(), decoded);
22006
+ parser.setXMLdata(newXmlData);
22007
+ parser.setCurrIndex(currrentIndex);
22008
+ }
21951
22009
  while (this.initInnerObjects(parser, parser.getNextTag(), dataView, task)) {
21952
22010
  }
21953
22011
  }
@@ -22693,10 +22751,12 @@ class Task extends TaskBase {
22693
22751
  this.setDescriptor(valueStr);
22694
22752
  break;
22695
22753
  case ConstInterface.MG_ATTR_HAS_LOCATE:
22696
- this.hasLocate = true;
22754
+ if (+valueStr == 1)
22755
+ this.hasLocate = true;
22697
22756
  break;
22698
22757
  case ConstInterface.MG_ATTR_AS_PARENT:
22699
- this.ModeAsParent = true;
22758
+ if (+valueStr == 1)
22759
+ this.ModeAsParent = true;
22700
22760
  break;
22701
22761
  case ConstInterface.MG_ATTR_TASK_UNIQUE_SORT:
22702
22762
  this.UniqueSort = valueStr[0];
@@ -23023,6 +23083,7 @@ class Task extends TaskBase {
23023
23083
  result = await this.DataviewManager.Execute(dataViewCommand);
23024
23084
  if (!result.Success)
23025
23085
  return null;
23086
+ this.ResumeSubformLayout();
23026
23087
  }
23027
23088
  nonInteractiveTask = await this.StartSubTasks(moveToFirstControl, nonInteractiveTask, callByDestSubForm);
23028
23089
  this.InStartProcess = false;
@@ -24646,16 +24707,16 @@ class Task extends TaskBase {
24646
24707
  }
24647
24708
  }
24648
24709
  }
24649
- ComputeMainDisplay() {
24710
+ async ComputeMainDisplay() {
24650
24711
  let propMainDisplay = this.getProp(PropInterface.PROP_TYPE_MAIN_DISPLAY);
24651
- let mainDisplayIndex = propMainDisplay.GetComputedValueInteger();
24712
+ let mainDisplayIndex = await propMainDisplay.getValueInt();
24652
24713
  mainDisplayIndex = this.GetRealMainDisplayIndexOnCurrentTask(mainDisplayIndex);
24653
24714
  this._forms.InitFormFromXmlString(mainDisplayIndex);
24654
24715
  this.EnsureValidForm();
24655
24716
  }
24656
24717
  async PrepareTaskForm() {
24657
24718
  await TaskServiceBase.PreparePropOpenTaskWindow(this);
24658
- return RemoteTaskService.PreparePropMainDisplay(this);
24719
+ return await RemoteTaskService.PreparePropMainDisplay(this);
24659
24720
  }
24660
24721
  FormIsLegal() {
24661
24722
  let isFormIsLegal = super.isMainProg();
@@ -24724,7 +24785,12 @@ class Task extends TaskBase {
24724
24785
  let tokensVector = XmlParser.getTokens(RuntimeContextBase.Instance.Parser.getXMLsubstring(endTaskUrlIdx), XMLConstants.XML_ATTR_DELIM);
24725
24786
  let taskCacheURL = tokensVector.get_Item(1);
24726
24787
  let refListStr = tokensVector.get_Item(3);
24727
- let taskContentOriginal = await Task.CommandsProcessor.GetContent(taskCacheURL, true);
24788
+ let taskContentOriginal = "";
24789
+ if (taskCacheURL.trim() != "") {
24790
+ if (taskCacheURL.startsWith("./"))
24791
+ taskCacheURL = NString.Replace(taskCacheURL, './', './assets/cache/');
24792
+ taskContentOriginal = await Task.CommandsProcessor.GetContent(taskCacheURL, true);
24793
+ }
24728
24794
  let taskContentFinal = new StringBuilder(xmlData.substr(0, RuntimeContextBase.Instance.Parser.getCurrIndex() - (ConstInterface.MG_TAG_TASKURL.length + 1)), taskContentOriginal.length);
24729
24795
  let reflist = this.getReflist(refListStr, ';', true, -1);
24730
24796
  let refListIdx = 0;
@@ -26924,7 +26990,7 @@ class EventsManager {
26924
26990
  val = Manager.GetCtrlVal(ctrl);
26925
26991
  task.CurrentEditingControl = null;
26926
26992
  if (!task.cancelWasRaised() &&
26927
- (ctrl.Type !== MgControlType.CTRL_TYPE_BROWSER && (!isNullOrUndefined(ctrl._field) && ctrl._field.getType() === StorageAttribute.DATE || val !== null) && typeof val != 'undefined' &&
26993
+ (ctrl.Type !== MgControlType.CTRL_TYPE_BROWSER && (!isNullOrUndefined(ctrl._field) && (ctrl._field.getType() === StorageAttribute.DATE || ctrl._field.getType() == StorageAttribute.NUMERIC) || val !== null) && typeof val != 'undefined' &&
26928
26994
  !await ctrl.validateAndSetValue(val, true))) {
26929
26995
  this.setStopExecution(true);
26930
26996
  return false;
@@ -29516,7 +29582,7 @@ class CommandsTable {
29516
29582
  }
29517
29583
  }
29518
29584
 
29519
- let CurrentClientVersion = '4.900.0-dev491.7';
29585
+ let CurrentClientVersion = '4.1000.0-dev000.0';
29520
29586
 
29521
29587
  class ClientManager {
29522
29588
  constructor() {
@@ -29607,6 +29673,10 @@ class ClientManager {
29607
29673
  EventsManager.Instance.addGuiTriggeredEventWithTaskAndCodeAndLine(task, InternalInterface.MG_ACT_REC_PREFIX, dvRowIdx);
29608
29674
  }
29609
29675
  break;
29676
+ case "navigateInTable":
29677
+ if (guiEvent.ControlName === "magicRow")
29678
+ this.handleNavigateInRowEvent(task, guiEvent.Value);
29679
+ break;
29610
29680
  case "close":
29611
29681
  if (task.IsRoute())
29612
29682
  EventsManager.Instance.AddRouterClosedEvent(task);
@@ -29641,6 +29711,38 @@ class ClientManager {
29641
29711
  break;
29642
29712
  }
29643
29713
  }
29714
+ handleNavigateInRowEvent(task, evt) {
29715
+ let internalEvt = InternalInterface.MG_ACT_NONE;
29716
+ evt = evt.toLowerCase();
29717
+ switch (evt) {
29718
+ case "begin-page":
29719
+ internalEvt = InternalInterface.MG_ACT_TBL_BEGPAGE;
29720
+ break;
29721
+ case "previous-page":
29722
+ internalEvt = InternalInterface.MG_ACT_TBL_PRVPAGE;
29723
+ break;
29724
+ case "end-page":
29725
+ internalEvt = InternalInterface.MG_ACT_TBL_ENDPAGE;
29726
+ break;
29727
+ case "next-page":
29728
+ internalEvt = InternalInterface.MG_ACT_TBL_NXTPAGE;
29729
+ break;
29730
+ case "previous-line":
29731
+ internalEvt = InternalInterface.MG_ACT_TBL_PRVLINE;
29732
+ break;
29733
+ case "next-line":
29734
+ internalEvt = InternalInterface.MG_ACT_TBL_NXTLINE;
29735
+ break;
29736
+ case "begin-table":
29737
+ internalEvt = InternalInterface.MG_ACT_TBL_BEGTBL;
29738
+ break;
29739
+ case "end-table":
29740
+ internalEvt = InternalInterface.MG_ACT_TBL_ENDTBL;
29741
+ break;
29742
+ }
29743
+ if (internalEvt != InternalInterface.MG_ACT_NONE)
29744
+ EventsManager.Instance.addGuiTriggeredEventWithTaskAndCode(task, internalEvt);
29745
+ }
29644
29746
  ConfirmationClosed(res) {
29645
29747
  Commands.ResolvePromise(res);
29646
29748
  }
@@ -29777,15 +29879,20 @@ class ClientManager {
29777
29879
  }
29778
29880
  return pic;
29779
29881
  }
29780
- static GetFormattedValue(taskId, controlName, value) {
29882
+ static GetFormattedValue(taskId, controlName, value, rowId) {
29781
29883
  let pic = null;
29782
29884
  let task = MGDataCollection.Instance.GetTaskByID(taskId);
29783
29885
  let control = null;
29784
29886
  let newValue = value;
29785
- if (controlName !== null)
29887
+ if (controlName !== null && task !== null)
29786
29888
  control = task.getForm().GetCtrl(controlName);
29787
29889
  if (control != null && control.DataType == StorageAttribute.NUMERIC) {
29788
- pic = control.getPIC();
29890
+ if (control.isRepeatable() && control.getProp(PropInterface.PROP_TYPE_FORMAT).isExpression()) {
29891
+ let picval = control.getProp(PropInterface.PROP_TYPE_FORMAT).getPrevValue(+rowId);
29892
+ pic = new PIC(picval, StorageAttribute.NUMERIC, control.getForm().getTask().getCompIdx());
29893
+ }
29894
+ else
29895
+ pic = control.getPIC();
29789
29896
  let dispValue = String(value);
29790
29897
  let newPic = pic.getUnformattedNumericPic();
29791
29898
  let num = DisplayConvertor.Instance.toNum(dispValue, newPic, 0);
@@ -29886,8 +29993,8 @@ class MagicBridge {
29886
29993
  static GetControlPictureMask(taskId, controlName) {
29887
29994
  return ClientManager.GetControlPictureMask(taskId, controlName);
29888
29995
  }
29889
- static GetFormattedValue(taskId, controlName, value) {
29890
- return ClientManager.GetFormattedValue(taskId, controlName, value);
29996
+ static GetFormattedValue(taskId, controlName, value, rowId) {
29997
+ return ClientManager.GetFormattedValue(taskId, controlName, value, rowId);
29891
29998
  }
29892
29999
  static GetRangedValue(taskId, controlName, value) {
29893
30000
  return ClientManager.GetRangedValue(taskId, controlName, value);
@@ -29906,13 +30013,6 @@ class MagicBridge {
29906
30013
  }
29907
30014
  }
29908
30015
 
29909
- class ControlItemsRefreshCommand extends DataviewCommand {
29910
- constructor() {
29911
- super();
29912
- this.Control = null;
29913
- }
29914
- }
29915
-
29916
30016
  class DataViewOutputCommand extends DataviewCommand {
29917
30017
  constructor(OutputCommandType) {
29918
30018
  super();