@coolon/angular-ui-powerups 12.4.0-alpha.32 → 12.4.0-alpha.34

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.
Files changed (33) hide show
  1. package/assets/interaction/editor/inline-string-editor.scss +4 -1
  2. package/bundles/coolon-angular-ui-powerups-cypress.umd.js +23 -9
  3. package/bundles/coolon-angular-ui-powerups-cypress.umd.js.map +1 -1
  4. package/bundles/coolon-angular-ui-powerups.umd.js +67 -13
  5. package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
  6. package/coolon-angular-ui-powerups.metadata.json +1 -1
  7. package/cypress/coolon-angular-ui-powerups-cypress.metadata.json +1 -1
  8. package/cypress/package.json +1 -1
  9. package/cypress/page.d.ts +3 -0
  10. package/esm2015/cypress/page.js +23 -9
  11. package/esm2015/cypress/page.js.map +1 -1
  12. package/esm2015/cypress/page.metadata.json +1 -1
  13. package/esm2015/lib/interaction/components/editors/inline-string-editor/inline-editor-model.js +18 -2
  14. package/esm2015/lib/interaction/components/editors/inline-string-editor/inline-editor-model.js.map +1 -1
  15. package/esm2015/lib/interaction/components/editors/inline-string-editor/inline-editor-model.metadata.json +1 -1
  16. package/esm2015/lib/interaction/components/editors/inline-string-editor/inline-string-editor.component.js +6 -4
  17. package/esm2015/lib/interaction/components/editors/inline-string-editor/inline-string-editor.component.js.map +1 -1
  18. package/esm2015/lib/interaction/components/editors/inline-string-editor/inline-string-editor.component.metadata.json +1 -1
  19. package/esm2015/lib/interaction/interaction.module.ngfactory.js.map +1 -1
  20. package/esm2015/lib/place/place-component.js +31 -4
  21. package/esm2015/lib/place/place-component.js.map +1 -1
  22. package/esm2015/lib/place/place-component.metadata.json +1 -1
  23. package/esm2015/lib/place/visit.js +5 -1
  24. package/esm2015/lib/place/visit.js.map +1 -1
  25. package/esm2015/lib/place/visit.metadata.json +1 -1
  26. package/fesm2015/coolon-angular-ui-powerups-cypress.js +23 -9
  27. package/fesm2015/coolon-angular-ui-powerups-cypress.js.map +1 -1
  28. package/fesm2015/coolon-angular-ui-powerups.js +57 -9
  29. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  30. package/lib/interaction/components/editors/inline-string-editor/inline-editor-model.d.ts +6 -2
  31. package/lib/interaction/components/editors/inline-string-editor/inline-string-editor.component.d.ts +2 -1
  32. package/lib/place/place-component.d.ts +6 -1
  33. package/package.json +1 -1
@@ -6741,13 +6741,35 @@
6741
6741
  _interactionContext: [{ type: i0.ViewChild, args: [PopupInteractionContextComponent, { static: true },] }]
6742
6742
  };
6743
6743
 
6744
- exports.InlineEditorModel = /** @class */ (function () {
6744
+ exports.InlineEditorModel = /** @class */ (function (_super) {
6745
+ __extends(InlineEditorModel, _super);
6745
6746
  function InlineEditorModel(valueModel, saveCallback) {
6746
- this.valueModel = valueModel;
6747
- this.saveCallback = saveCallback;
6748
- this.editing = new pectin.MutableValueModel(false);
6749
- this._validators = new pectin.MutableListModel();
6747
+ var _this = _super.call(this) || this;
6748
+ _this.valueModel = valueModel;
6749
+ _this.saveCallback = saveCallback;
6750
+ _this.editing = new pectin.MutableValueModel(false);
6751
+ _this._validators = new pectin.MutableListModel();
6752
+ _this._editingEnabled = _this.registerDisposable(new pectin.DelegatingValueModel().withDefault(true));
6753
+ var when = pectin.Dsl.disposeWith(_this).when;
6754
+ when(_this.editingEnabled).becomesFalsey(function () { return _this.cancelEdit(); });
6755
+ return _this;
6750
6756
  }
6757
+ Object.defineProperty(InlineEditorModel.prototype, "editingEnabled", {
6758
+ get: function () {
6759
+ return this._editingEnabled.readonly;
6760
+ },
6761
+ enumerable: false,
6762
+ configurable: true
6763
+ });
6764
+ InlineEditorModel.prototype.disableWhile = function (condition) {
6765
+ var chain = pectin.Dsl.disposeWith(this).chain;
6766
+ this.enableWhile(chain(condition).isFalsey());
6767
+ return this;
6768
+ };
6769
+ InlineEditorModel.prototype.enableWhile = function (condition) {
6770
+ this._editingEnabled.setDelegate(condition);
6771
+ return this;
6772
+ };
6751
6773
  Object.defineProperty(InlineEditorModel.prototype, "validators", {
6752
6774
  get: function () {
6753
6775
  return this._validators.readonly;
@@ -6770,7 +6792,7 @@
6770
6792
  this.editing.value = true;
6771
6793
  };
6772
6794
  return InlineEditorModel;
6773
- }());
6795
+ }(pectin.GarbageCollector));
6774
6796
  (function (InlineEditorModel) {
6775
6797
  function create(valueModel, options) {
6776
6798
  return new InlineEditorModel(valueModel, options.save);
@@ -6801,6 +6823,7 @@
6801
6823
  __extends(InlineStringEditorComponent, _super);
6802
6824
  function InlineStringEditorComponent(interactionService) {
6803
6825
  var _this = _super.call(this) || this;
6826
+ _this.editingEnabled = _this.registerDisposable(new pectin.DelegatingValueModel());
6804
6827
  var _a = pectin.Dsl.disposeWith(_this), chain = _a.chain, when = _a.when, valueOf = _a.valueOf;
6805
6828
  var modalIC = interactionService.createModalInteractionContextDisposedWith(_this);
6806
6829
  var resolvedFacesModel = chain(_this.facesModel).map(function (userFaces) {
@@ -6832,7 +6855,7 @@
6832
6855
  case 5: return [2 /*return*/];
6833
6856
  }
6834
6857
  });
6835
- }); });
6858
+ }); }).enableWhile(_this.editingEnabled);
6836
6859
  _this.onDispose(function () { return _this.cancelEdit(); });
6837
6860
  return _this;
6838
6861
  }
@@ -6844,6 +6867,7 @@
6844
6867
  if (!this.editorModel) {
6845
6868
  typescriptUtilities.lang.illegalState('editorModel is required');
6846
6869
  }
6870
+ this.editingEnabled.setDelegate(this.editorModel.editingEnabled);
6847
6871
  when(this.editorModel.editing).becomesTruthy(function () {
6848
6872
  _this.editCommand.execute();
6849
6873
  }, { asLongAs: this.editCommand.enabled });
@@ -6899,7 +6923,7 @@
6899
6923
  exports.InlineStringEditorComponent.decorators = [
6900
6924
  { type: i0.Component, args: [{
6901
6925
  selector: 'aup-inline-string-editor',
6902
- template: "<ng-container *ngIf=\"!editorModel.isEditing()\">\n <div class=\"content\" [class.editable]=\"editCommand.enabled.value\">\n <label>{{label}}</label>\n <p [class.place-holder]=\"empty.value\" (click)=\"editCommand.execute()\">{{displayValue.value}}</p>\n <aup-command *ngIf=\"editCommand.enabled.value\" [command]=\"editCommand\" [faceModel]=\"editFaceModel\"></aup-command>\n </div>\n</ng-container>\n<aup-in-place-interaction-context #interactionContext [animateFirstActivity]=\"false\"></aup-in-place-interaction-context>\n\n"
6926
+ template: "<ng-container *ngIf=\"!editorModel.isEditing()\">\n <div class=\"content\" [class.editable]=\"editCommand.enabled.value\">\n <label>{{label}}</label>\n <p [class.place-holder]=\"empty.value\" [class.editing-enabled]=\"editingEnabled.value\" (click)=\"editCommand.execute()\">{{displayValue.value}}</p>\n <aup-command *ngIf=\"editCommand.enabled.value\" [command]=\"editCommand\" [faceModel]=\"editFaceModel\"></aup-command>\n </div>\n</ng-container>\n<aup-in-place-interaction-context #interactionContext [animateFirstActivity]=\"false\"></aup-in-place-interaction-context>\n\n"
6903
6927
  },] }
6904
6928
  ];
6905
6929
  exports.InlineStringEditorComponent.ctorParameters = function () { return [
@@ -7321,17 +7345,28 @@
7321
7345
  _this.childPlaces = _this.placeDefinition.children.map(function (d) { return d.component; });
7322
7346
  return _this;
7323
7347
  }
7324
- // @Trace()
7325
7348
  PlaceComponent.prototype.initialiseVisit = function (visit, notifyVisitChanged) {
7326
7349
  var _this = this;
7327
7350
  pectin.assert.isNil(this.visitModel.value);
7328
7351
  var when = pectin.Dsl.disposeWith(this).when;
7329
7352
  this.visitModel.value = visit;
7330
7353
  pectin.DebugContext.getOrCreate(this.visitModel).tag(this.placeDefinition.component.name + ".visitModel");
7331
- this.placeDefinition.getVisitParameterDefs().forEach(function (parameterDef) { return _this.installBinding(parameterDef); });
7354
+ // we track if the any of the bindings updated the route. If so we remember it and update the
7355
+ // route in one go at the end.
7356
+ this.placeDefinition
7357
+ .getVisitParameterDefs()
7358
+ .forEach(function (parameterDef) { return _this.installAndInitialiseBinding(visit, parameterDef); });
7332
7359
  when(this.visitModel).changes(function (current, previous) {
7333
7360
  notifyVisitChanged(current, previous);
7334
7361
  }, { unless: this._inVisitUpdate });
7362
+ // TODO: this needs to do a replace url option so that the new url isn't put in the history.... for
7363
+ // now we're not doing it as it's a fair bit of effort and will only affect people if they're
7364
+ // cutting and pasting urls to each other.
7365
+ // // the binding process can update the visit (e.g. if a selection model has already selected during
7366
+ // // component construction) and there was no value specified in the route
7367
+ // if (visit.hasRoutingChangedFrom(this.visitModel.value)) {
7368
+ // notifyVisitChanged(this.visitModel.value, visit)
7369
+ // }
7335
7370
  };
7336
7371
  PlaceComponent.prototype.updateVisit = function (visit) {
7337
7372
  var _this = this;
@@ -7345,7 +7380,12 @@
7345
7380
  return !!this.visitModel.value;
7346
7381
  };
7347
7382
  // @Trace()
7348
- PlaceComponent.prototype.installBinding = function (parameterDef) {
7383
+ /**
7384
+ * Initialised the component bindings. If any binding has an initial model value (e.g. a selection model
7385
+ * initialised during the constructor) and the route has nothing, then the visit will be udpated and this
7386
+ * method will return ture to nofiy the the visit has changed.
7387
+ */
7388
+ PlaceComponent.prototype.installAndInitialiseBinding = function (initialVisit, parameterDef) {
7349
7389
  var model = this[parameterDef.propertyName];
7350
7390
  pectin.DebugContext.tag(model, this.placeDefinition.component.name + "." + parameterDef.propertyName);
7351
7391
  var binding = this.registerDisposable(new pectin.Binding(this.visitModel, model, {
@@ -7359,7 +7399,17 @@
7359
7399
  return currentVisit.replace(parameterDef, value);
7360
7400
  }
7361
7401
  }));
7362
- binding.writeRight();
7402
+ // Now we need to initialise the binding direction. If we have a value in the Url then we should always push
7403
+ // that to the view. If we don't and the view already has a value (e.g. a selection model has already initialised in the
7404
+ // component constructor) then we should push that to the route.
7405
+ var isInVisit = !___namespace.isNil(initialVisit.getParameterValue(parameterDef));
7406
+ var isInModel = !___namespace.isNil(model.value);
7407
+ if (!isInVisit && isInModel) {
7408
+ binding.writeLeft(); // push it to the route
7409
+ }
7410
+ else {
7411
+ binding.writeRight(); // push it to the model
7412
+ }
7363
7413
  };
7364
7414
  Object.defineProperty(PlaceComponent.prototype, "placeDefinition", {
7365
7415
  get: function () {
@@ -8620,9 +8670,13 @@
8620
8670
  });
8621
8671
  return new Visit(this.placeDefinition, params);
8622
8672
  };
8673
+ // @Trace()
8623
8674
  Visit.prototype.hasRoutingChangedFrom = function (other) {
8624
8675
  var samePlace = other.placeDefinition === this.placeDefinition;
8625
- var sameRouteParameters = ___namespace.isEqual(this.placeDefinition.getFormattedRouteParameters(this, true), this.placeDefinition.getFormattedRouteParameters(other, true));
8676
+ var currentParams = this.placeDefinition.getFormattedRouteParameters(this, true);
8677
+ var otherParams = this.placeDefinition.getFormattedRouteParameters(other, true);
8678
+ // console.log({currentParams, otherParams});
8679
+ var sameRouteParameters = ___namespace.isEqual(currentParams, otherParams);
8626
8680
  return !samePlace || !sameRouteParameters;
8627
8681
  };
8628
8682
  Visit.prototype.hasChangedFrom = function (other) {