@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
@@ -5732,12 +5732,28 @@ PopupActivityTriggerComponent.propDecorators = {
5732
5732
  _interactionContext: [{ type: ViewChild, args: [PopupInteractionContextComponent, { static: true },] }]
5733
5733
  };
5734
5734
 
5735
- class InlineEditorModel {
5735
+ class InlineEditorModel extends GarbageCollector {
5736
5736
  constructor(valueModel, saveCallback) {
5737
+ super();
5737
5738
  this.valueModel = valueModel;
5738
5739
  this.saveCallback = saveCallback;
5739
5740
  this.editing = new MutableValueModel(false);
5740
5741
  this._validators = new MutableListModel();
5742
+ this._editingEnabled = this.registerDisposable(new DelegatingValueModel().withDefault(true));
5743
+ const { when } = Dsl.disposeWith(this);
5744
+ when(this.editingEnabled).becomesFalsey(() => this.cancelEdit());
5745
+ }
5746
+ get editingEnabled() {
5747
+ return this._editingEnabled.readonly;
5748
+ }
5749
+ disableWhile(condition) {
5750
+ const { chain } = Dsl.disposeWith(this);
5751
+ this.enableWhile(chain(condition).isFalsey());
5752
+ return this;
5753
+ }
5754
+ enableWhile(condition) {
5755
+ this._editingEnabled.setDelegate(condition);
5756
+ return this;
5741
5757
  }
5742
5758
  get validators() {
5743
5759
  return this._validators.readonly;
@@ -5786,6 +5802,7 @@ TrackExternal.oneTimeBinding(InlineEditorModel);
5786
5802
  class InlineStringEditorComponent extends DisposableComponent {
5787
5803
  constructor(interactionService) {
5788
5804
  super();
5805
+ this.editingEnabled = this.registerDisposable(new DelegatingValueModel());
5789
5806
  const { chain, when, valueOf } = Dsl.disposeWith(this);
5790
5807
  const modalIC = interactionService.createModalInteractionContextDisposedWith(this);
5791
5808
  const resolvedFacesModel = chain(this.facesModel).map(userFaces => {
@@ -5801,12 +5818,12 @@ class InlineStringEditorComponent extends DisposableComponent {
5801
5818
  yield this.interactionContext.startActivity(StringInputActivity, this.createInputActivityData());
5802
5819
  }
5803
5820
  catch (e) {
5804
- // don't care, just hiding the console errors
5821
+ // don't care if they cancelled, just hiding the console errors
5805
5822
  }
5806
5823
  finally {
5807
5824
  this.editorModel.editing.value = false;
5808
5825
  }
5809
- }));
5826
+ })).enableWhile(this.editingEnabled);
5810
5827
  this.onDispose(() => this.cancelEdit());
5811
5828
  }
5812
5829
  ngOnInit() {
@@ -5816,6 +5833,7 @@ class InlineStringEditorComponent extends DisposableComponent {
5816
5833
  if (!this.editorModel) {
5817
5834
  lang$1.illegalState('editorModel is required');
5818
5835
  }
5836
+ this.editingEnabled.setDelegate(this.editorModel.editingEnabled);
5819
5837
  when(this.editorModel.editing).becomesTruthy(() => {
5820
5838
  this.editCommand.execute();
5821
5839
  }, { asLongAs: this.editCommand.enabled });
@@ -5863,7 +5881,7 @@ class InlineStringEditorComponent extends DisposableComponent {
5863
5881
  InlineStringEditorComponent.decorators = [
5864
5882
  { type: Component, args: [{
5865
5883
  selector: 'aup-inline-string-editor',
5866
- 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"
5884
+ 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"
5867
5885
  },] }
5868
5886
  ];
5869
5887
  InlineStringEditorComponent.ctorParameters = () => [
@@ -6251,16 +6269,27 @@ class PlaceComponent extends DisposableComponent {
6251
6269
  when(this._active).becomesTruthy(() => this._notifyPlaceReady());
6252
6270
  this.childPlaces = this.placeDefinition.children.map(d => d.component);
6253
6271
  }
6254
- // @Trace()
6255
6272
  initialiseVisit(visit, notifyVisitChanged) {
6256
6273
  assert.isNil(this.visitModel.value);
6257
6274
  const { when } = Dsl.disposeWith(this);
6258
6275
  this.visitModel.value = visit;
6259
6276
  DebugContext.getOrCreate(this.visitModel).tag(`${this.placeDefinition.component.name}.visitModel`);
6260
- this.placeDefinition.getVisitParameterDefs().forEach(parameterDef => this.installBinding(parameterDef));
6277
+ // we track if the any of the bindings updated the route. If so we remember it and update the
6278
+ // route in one go at the end.
6279
+ this.placeDefinition
6280
+ .getVisitParameterDefs()
6281
+ .forEach(parameterDef => this.installAndInitialiseBinding(visit, parameterDef));
6261
6282
  when(this.visitModel).changes((current, previous) => {
6262
6283
  notifyVisitChanged(current, previous);
6263
6284
  }, { unless: this._inVisitUpdate });
6285
+ // TODO: this needs to do a replace url option so that the new url isn't put in the history.... for
6286
+ // now we're not doing it as it's a fair bit of effort and will only affect people if they're
6287
+ // cutting and pasting urls to each other.
6288
+ // // the binding process can update the visit (e.g. if a selection model has already selected during
6289
+ // // component construction) and there was no value specified in the route
6290
+ // if (visit.hasRoutingChangedFrom(this.visitModel.value)) {
6291
+ // notifyVisitChanged(this.visitModel.value, visit)
6292
+ // }
6264
6293
  }
6265
6294
  updateVisit(visit) {
6266
6295
  assert.isTruthy(this.isInitialised());
@@ -6273,7 +6302,12 @@ class PlaceComponent extends DisposableComponent {
6273
6302
  return !!this.visitModel.value;
6274
6303
  }
6275
6304
  // @Trace()
6276
- installBinding(parameterDef) {
6305
+ /**
6306
+ * Initialised the component bindings. If any binding has an initial model value (e.g. a selection model
6307
+ * initialised during the constructor) and the route has nothing, then the visit will be udpated and this
6308
+ * method will return ture to nofiy the the visit has changed.
6309
+ */
6310
+ installAndInitialiseBinding(initialVisit, parameterDef) {
6277
6311
  const model = this[parameterDef.propertyName];
6278
6312
  DebugContext.tag(model, `${this.placeDefinition.component.name}.${parameterDef.propertyName}`);
6279
6313
  const binding = this.registerDisposable(new Binding(this.visitModel, model, {
@@ -6287,7 +6321,17 @@ class PlaceComponent extends DisposableComponent {
6287
6321
  return currentVisit.replace(parameterDef, value);
6288
6322
  }
6289
6323
  }));
6290
- binding.writeRight();
6324
+ // Now we need to initialise the binding direction. If we have a value in the Url then we should always push
6325
+ // 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
6326
+ // component constructor) then we should push that to the route.
6327
+ const isInVisit = !_.isNil(initialVisit.getParameterValue(parameterDef));
6328
+ const isInModel = !_.isNil(model.value);
6329
+ if (!isInVisit && isInModel) {
6330
+ binding.writeLeft(); // push it to the route
6331
+ }
6332
+ else {
6333
+ binding.writeRight(); // push it to the model
6334
+ }
6291
6335
  }
6292
6336
  get placeDefinition() {
6293
6337
  const definition = PlaceComponent.getDefinition(this.constructor);
@@ -7407,9 +7451,13 @@ class Visit {
7407
7451
  });
7408
7452
  return new Visit(this.placeDefinition, params);
7409
7453
  }
7454
+ // @Trace()
7410
7455
  hasRoutingChangedFrom(other) {
7411
7456
  const samePlace = other.placeDefinition === this.placeDefinition;
7412
- const sameRouteParameters = _.isEqual(this.placeDefinition.getFormattedRouteParameters(this, true), this.placeDefinition.getFormattedRouteParameters(other, true));
7457
+ const currentParams = this.placeDefinition.getFormattedRouteParameters(this, true);
7458
+ const otherParams = this.placeDefinition.getFormattedRouteParameters(other, true);
7459
+ // console.log({currentParams, otherParams});
7460
+ const sameRouteParameters = _.isEqual(currentParams, otherParams);
7413
7461
  return !samePlace || !sameRouteParameters;
7414
7462
  }
7415
7463
  hasChangedFrom(other) {