mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[AAE-10767] Separate core card view logic from content-services and add documentation to reflect the changes (#7952)
This commit is contained in:
parent
8d074e8b33
commit
02578dcdc5
@ -0,0 +1,51 @@
|
|||||||
|
---
|
||||||
|
Title: Base Card View Content Update interface
|
||||||
|
Added: v6.0.0
|
||||||
|
Status: Active
|
||||||
|
Last reviewed: 2022-11-25
|
||||||
|
---
|
||||||
|
|
||||||
|
# [Base Card View Content Update interface](../../../lib/content-services/src/lib/interfaces/base-card-view-content-update.interface.ts "Defined in base-card-view-content-update.interface.ts")
|
||||||
|
|
||||||
|
Specifies required properties and methods for [Card View Content Update service](../../../lib/content-services/src/lib/services/card-view-content-update.service.ts).
|
||||||
|
Extends from [`BaseCardViewUpdate`](../../../lib/core/src/lib/card-view/interfaces/base-card-view-update.interface.ts).
|
||||||
|
|
||||||
|
## Basic usage
|
||||||
|
|
||||||
|
```ts
|
||||||
|
export interface BaseCardViewContentUpdate {
|
||||||
|
itemUpdated$: Subject<UpdateNotification>;
|
||||||
|
updatedAspect$: Subject<MinimalNode>;
|
||||||
|
|
||||||
|
update(property: CardViewBaseItemModel, newValue: any);
|
||||||
|
updateElement(notification: CardViewBaseItemModel);
|
||||||
|
updateNodeAspect(node: MinimalNode);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Properties
|
||||||
|
|
||||||
|
| Name | Type | Default value | Description |
|
||||||
|
| ---- | ---- | ------------- | ----------- |
|
||||||
|
| itemUpdated$ | [`Subject`](http://reactivex.io/documentation/subject.html)`<`[`UpdateNotification`](../../../lib/core/src/lib/card-view/interfaces/update-notification.interface.ts)`>` | | The current updated item. |
|
||||||
|
| updatedAspect$ | [`Subject`](http://reactivex.io/documentation/subject.html)`<`[`MinimalNode`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodeMinimalEntry.md)`>`(@alfresco/js-api) | | [Subject](http://reactivex.io/documentation/subject.html) holding the current node |
|
||||||
|
|
||||||
|
### Methods
|
||||||
|
|
||||||
|
- **update**(property: [`CardViewBaseItemModel`](../../../lib/core/src/lib/card-view/models/card-view-baseitem.model.ts), newValue: `any`)<br/>
|
||||||
|
Update itemUpdated$ property.
|
||||||
|
|
||||||
|
- property:\_ [`CardViewBaseItemModel`](../../../lib/core/src/lib/card-view/models/card-view-baseitem.model.ts) - The property.
|
||||||
|
- newValue:\_ `any` - new value.
|
||||||
|
|
||||||
|
- **updateElement**(notification: [`CardViewBaseItemModel`](../../../lib/core/src/lib/card-view/models/card-view-baseitem.model.ts))<br/>
|
||||||
|
Update updateItem$ observable.
|
||||||
|
- notification:\_ [`CardViewBaseItemModel`](../../../lib/core/src/lib/card-view/models/card-view-baseitem.model.ts) - The notification.
|
||||||
|
|
||||||
|
- **updateNodeAspect**(node: [`MinimalNode`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodeMinimalEntry.md))<br/>
|
||||||
|
Update node aspect observable.
|
||||||
|
- node:\_ [`MinimalNode`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodeMinimalEntry.md) - The node.
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
- [CardViewContentUpdate service](../services/card-view-content-update.service.md)
|
@ -0,0 +1,35 @@
|
|||||||
|
---
|
||||||
|
Title: Card View Content Update Service
|
||||||
|
Added: v6.0.0
|
||||||
|
Status: Active
|
||||||
|
Last reviewed: 2022-11-25
|
||||||
|
---
|
||||||
|
|
||||||
|
# [Card View Content Update Service](../../../lib/content-services/src/lib/services/card-view-content-update.service.ts "Defined in card-view-content-update.service.ts")
|
||||||
|
|
||||||
|
Manages Card View properties in the content services environment.
|
||||||
|
Implements [`BaseCardViewContentUpdate`](../../../lib/content-services/src/lib/interfaces/base-card-view-content-update.interface.ts).
|
||||||
|
|
||||||
|
## Class members
|
||||||
|
|
||||||
|
### Methods
|
||||||
|
|
||||||
|
- **update**(property: [`CardViewBaseItemModel`](../../../lib/core/src/lib/card-view/models/card-view-baseitem.model.ts), newValue: `any`)<br/>
|
||||||
|
|
||||||
|
- _property:_ [`CardViewBaseItemModel`](../../../lib/core/src/lib/card-view/models/card-view-baseitem.model.ts)
|
||||||
|
- _newValue:_ `any`
|
||||||
|
|
||||||
|
- **updateElement**(notification: [`CardViewBaseItemModel`](../../../lib/core/src/lib/card-view/models/card-view-baseitem.model.ts))<br/>
|
||||||
|
Updates the cardview items property
|
||||||
|
- _notification:_ [`CardViewBaseItemModel`](../../../lib/core/src/lib/card-view/models/card-view-baseitem.model.ts)
|
||||||
|
|
||||||
|
- **updateNodeAspect**(node: [`MinimalNode`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodeMinimalEntry.md))<br/>
|
||||||
|
Update node aspect observable.
|
||||||
|
- _node:_ [`MinimalNode`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodeMinimalEntry.md)
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ---- | ---- | ----------- |
|
||||||
|
| itemUpdated$ | [`Subject`](http://reactivex.io/documentation/subject.html)`<`[`UpdateNotification`](../../../lib/core/src/lib/card-view/interfaces/update-notification.interface.ts)`>` | The current updated item. |
|
||||||
|
| updateAspect$ | [`Subject`](http://reactivex.io/documentation/subject.html)`<`[`MinimalNode`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodeMinimalEntry.md)`>`(@alfresco/js-api) | The current Node. |
|
53
docs/core/interfaces/base-card-view-update.interface.md
Normal file
53
docs/core/interfaces/base-card-view-update.interface.md
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
---
|
||||||
|
Title: Base Card View Update Interface
|
||||||
|
Added: v6.0.0
|
||||||
|
Status: Active
|
||||||
|
Last reviewed: 2022-11-25
|
||||||
|
---
|
||||||
|
|
||||||
|
# [Base Card View Update interface](../../../lib/core/src/lib/card-view/interfaces/base-card-view-update.interface.ts "Defined in base-card-view-update.interface.ts")
|
||||||
|
|
||||||
|
Specifies required properties and methods for [Card View Update service](../../../lib/core/src/lib/card-view/services/card-view-update.service.ts).
|
||||||
|
|
||||||
|
## Basic usage
|
||||||
|
|
||||||
|
```ts
|
||||||
|
export interface BaseCardViewUpdate {
|
||||||
|
itemUpdated$: Subject<UpdateNotification>;
|
||||||
|
itemClicked$: Subject<ClickNotification>;
|
||||||
|
updateItem$: Subject<CardViewBaseItemModel>;
|
||||||
|
|
||||||
|
update(property: CardViewBaseItemModel, newValue: any);
|
||||||
|
clicked(property: CardViewBaseItemModel);
|
||||||
|
updateElement(notification: CardViewBaseItemModel);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ---- | ---- | ----------- |
|
||||||
|
| itemUpdated$ | [`Subject`](http://reactivex.io/documentation/subject.html)`<`[`UpdateNotification`](../../../lib/core/src/lib/card-view/interfaces/update-notification.interface.ts)`>` | The current updated item. |
|
||||||
|
| itemClicked$ | [`Subject`](http://reactivex.io/documentation/subject.html)`<`[`ClickNotification`](../../../lib/core/src/lib/card-view/interfaces/click-notification.interface.ts)`>` | The current clicked item. |
|
||||||
|
| updateItem$ | [`Subject`](http://reactivex.io/documentation/subject.html)`<`[`CardViewBaseItemModel`](../../../lib/core/src/lib/card-view/models/card-view-baseitem.model.ts)`>` | The current model for the update item. |
|
||||||
|
|
||||||
|
### Methods
|
||||||
|
|
||||||
|
- **update**(property: [`CardViewBaseItemModel`](../../../lib/core/src/lib/card-view/models/card-view-baseitem.model.ts), newValue: `any`)<br/>
|
||||||
|
Update itemUpdated$ property.
|
||||||
|
|
||||||
|
- property:\_ [`CardViewBaseItemModel`](../../../lib/core/src/lib/card-view/models/card-view-baseitem.model.ts) - The property.
|
||||||
|
- newValue:\_ `any` - new value.
|
||||||
|
|
||||||
|
- **clicked**(property: [`CardViewBaseItemModel`](../../../lib/core/src/lib/card-view/models/card-view-baseitem.model.ts))<br/>
|
||||||
|
Update itemClicked$ property.
|
||||||
|
|
||||||
|
- property:\_ [`CardViewBaseItemModel`](../../../lib/core/src/lib/card-view/models/card-view-baseitem.model.ts) - The property.
|
||||||
|
|
||||||
|
- **updateElement**(notification: [`CardViewBaseItemModel`](../../../lib/core/src/lib/card-view/models/card-view-baseitem.model.ts))<br/>
|
||||||
|
Update updateItem$ observable.
|
||||||
|
- notification:\_ [`CardViewBaseItemModel`](../../../lib/core/src/lib/card-view/models/card-view-baseitem.model.ts) - The notification.
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
- [CardViewUpdate service](../services/card-view-update.service.md)
|
26
docs/core/interfaces/click-notification.interface.md
Normal file
26
docs/core/interfaces/click-notification.interface.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
Title: Click Notification Interface
|
||||||
|
Added: v6.0.0
|
||||||
|
Status: Active
|
||||||
|
Last reviewed: 2022-11-25
|
||||||
|
---
|
||||||
|
|
||||||
|
# [Click Notification Interface](../../../lib/core/src/lib/card-view/interfaces/click-notification.interface.ts "Defined in click-notification.interface.ts")
|
||||||
|
|
||||||
|
## Basic usage
|
||||||
|
|
||||||
|
```ts
|
||||||
|
export interface ClickNotification {
|
||||||
|
target: any;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ---- | ---- | ----------- |
|
||||||
|
| target | `any` | The target for the click notification. |
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
- [BaseCardViewUpdate interface](../interfaces/base-card-view-update.interface.md)
|
28
docs/core/interfaces/update-notification.interface.md
Normal file
28
docs/core/interfaces/update-notification.interface.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
Title: Update Notification Interface
|
||||||
|
Added: v6.0.0
|
||||||
|
Status: Active
|
||||||
|
Last reviewed: 2022-11-25
|
||||||
|
---
|
||||||
|
|
||||||
|
# [Update Notification Interface](../../../lib/core/src/lib/card-view/interfaces/update-notification.interface.ts "Defined in update-notification.interface.ts")
|
||||||
|
|
||||||
|
## Basic usage
|
||||||
|
|
||||||
|
```ts
|
||||||
|
export interface UpdateNotification {
|
||||||
|
target: CardViewBaseItemModel;
|
||||||
|
changed: any;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ---- | ---- | ----------- |
|
||||||
|
| target | [`CardViewBaseItemModel`](../../../lib/core/src/lib/card-view/models/card-view-baseitem.model.ts) | The target for the update notification. |
|
||||||
|
| changed | `any` | The changed value on the update notification. |
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
- [BaseCardViewUpdate interface](../interfaces/base-card-view-update.interface.md)
|
@ -2,12 +2,13 @@
|
|||||||
Title: Card View Update service
|
Title: Card View Update service
|
||||||
Added: v2.0.0
|
Added: v2.0.0
|
||||||
Status: Active
|
Status: Active
|
||||||
Last reviewed: 2018-11-14
|
Last reviewed: 2022-11-25
|
||||||
---
|
---
|
||||||
|
|
||||||
# [Card View Update service](lib/core/src/lib/card-view/services/card-view-update.service.ts "Defined in card-view-update.service.ts")
|
# [Card View Update service](../../../lib/core/src/lib/card-view/services/card-view-update.service.ts "Defined in card-view-update.service.ts")
|
||||||
|
|
||||||
Reports edits and clicks within fields of a [Card View component](../components/card-view.component.md).
|
Reports edits and clicks within fields of a [Card View component](../components/card-view.component.md).
|
||||||
|
Implements [`BaseCardViewUpdate`](../../../lib/core/src/lib/card-view/interfaces/base-card-view-update.interface.ts).
|
||||||
|
|
||||||
## Details
|
## Details
|
||||||
|
|
||||||
@ -55,7 +56,7 @@ constructor(private cardViewUpdateService: CardViewUpdateService) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The constructor here also sets the [`CardViewTextItemModel`](lib/core/src/lib/card-view/models/card-view-textitem.model.ts) instances that define the layout of the
|
The constructor here also sets the [`CardViewTextItemModel`](../../../lib/core/src/lib/card-view/models/card-view-textitem.model.ts) instances that define the layout of the
|
||||||
card view (see the [Card View component](../components/card-view.component.md) for further information
|
card view (see the [Card View component](../components/card-view.component.md) for further information
|
||||||
about this). The model objects and the `key` property are used to identify which item has been clicked
|
about this). The model objects and the `key` property are used to identify which item has been clicked
|
||||||
or updated when an event occurs.
|
or updated when an event occurs.
|
||||||
@ -77,7 +78,7 @@ called after updates and clicks, respectively.
|
|||||||
|
|
||||||
### Responding to updates
|
### Responding to updates
|
||||||
|
|
||||||
The update function is passed a parameter of type [`UpdateNotification`](lib/core/src/lib/card-view/services/card-view-update.service.ts):
|
The update function is passed a parameter of type [`UpdateNotification`](../../../lib/core/src/lib/card-view/interfaces/update-notification.interface.ts):
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
export interface UpdateNotification {
|
export interface UpdateNotification {
|
||||||
@ -86,8 +87,8 @@ export interface UpdateNotification {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Here, `target` contains the [`CardViewTextItemModel`](lib/core/src/lib/card-view/models/card-view-textitem.model.ts) that was used to initialize
|
Here, `target` contains the [`CardViewTextItemModel`](../../../lib/core/src/lib/card-view/models/card-view-textitem.model.ts) that was used to initialize
|
||||||
the field in question (in practice, this might be a [`CardViewDateItemModel`](lib/core/src/lib/card-view/models/card-view-dateitem.model.ts) or [`CardViewMapItemModel`](lib/core/src/lib/card-view/models/card-view-mapitem.model.ts) if
|
the field in question (in practice, this might be a [`CardViewDateItemModel`](../../../lib/core/src/lib/card-view/models/card-view-dateitem.model.ts) or [`CardViewMapItemModel`](../../../lib/core/src/lib/card-view/models/card-view-mapitem.model.ts) if
|
||||||
the card layout includes these objects). The `changed` property contains an object with a single property:
|
the card layout includes these objects). The `changed` property contains an object with a single property:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
@ -115,7 +116,7 @@ on the [Card View component](../components/card-view.component.md) itself.
|
|||||||
|
|
||||||
### Responding to clicks
|
### Responding to clicks
|
||||||
|
|
||||||
The click function is passed a [`ClickNotification`](lib/core/src/lib/card-view/services/card-view-update.service.ts) object, which is similar to [`UpdateNotification`](lib/core/src/lib/card-view/services/card-view-update.service.ts) described above,
|
The click function is passed a [`ClickNotification`](../../../lib/core/src/lib/card-view/interfaces/click-notification.interface.ts) object, which is similar to [`UpdateNotification`](../../../lib/core/src/lib/card-view/interfaces/update-notification.interface.ts) described above,
|
||||||
but without the `changed` property. Use the `target` property to identify the item that was clicked:
|
but without the `changed` property. Use the `target` property to identify the item that was clicked:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
@ -128,7 +129,7 @@ Note that this function will only be called if the `clickable` property of the m
|
|||||||
|
|
||||||
## Update cardview update item
|
## Update cardview update item
|
||||||
|
|
||||||
[`updateElement`](lib/core/src/lib/card-view/services/card-view-update.service.ts) function helps to update the card view item. It takes the [`CardViewBaseItemModel`](lib/core/src/lib/card-view/models/card-view-baseitem.model.ts) type object as parameter.
|
[`updateElement`](../../../lib/core/src/lib/card-view/services/card-view-update.service.ts) function helps to update the card view item. It takes the [`CardViewBaseItemModel`](../../../lib/core/src/lib/card-view/models/card-view-baseitem.model.ts) type object as parameter.
|
||||||
|
|
||||||
Example
|
Example
|
||||||
|
|
||||||
@ -139,3 +140,5 @@ Example
|
|||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [Card view component](../components/card-view.component.md)
|
- [Card view component](../components/card-view.component.md)
|
||||||
|
- [UpdateNotification interface](../interfaces/update-notification.interface.md)
|
||||||
|
- [ClickNotification interface](../interfaces/click-notification.interface.md)
|
||||||
|
@ -81,6 +81,17 @@ How to fix it:
|
|||||||
|
|
||||||
Following classes have been relocated:
|
Following classes have been relocated:
|
||||||
- `VersionCompatibilityService` and `VersionCompatibilityDirective` relocated from `@alfresco/adf-core` to `@alfresco/adf-content-services`
|
- `VersionCompatibilityService` and `VersionCompatibilityDirective` relocated from `@alfresco/adf-core` to `@alfresco/adf-content-services`
|
||||||
|
The following directives have been moved from the Core library to the Content Services
|
||||||
|
library. You should modify your code to import these classes from
|
||||||
|
`@alfresco/adf-content-services`.
|
||||||
|
|
||||||
|
- [`CheckAllowableOperationDirective`](lib/content-services/src/lib/directives/check-allowable-operation.directive.ts)
|
||||||
|
- [`LibraryFavoriteDirective`](lib/content-services/src/lib/directives/library-favorite.directive.ts)
|
||||||
|
- [`LibraryMembershipDirective`](lib/content-services/src/lib/directives/library-membership.directive.ts)
|
||||||
|
- [`NodeDeleteDirective`](lib/content-services/src/lib/directives/node-delete.directive.ts)
|
||||||
|
- [`NodeFavoriteDirective`](lib/content-services/src/lib/directives/node-favorite.directive.ts)
|
||||||
|
- [`NodeRestoreDirective`](lib/content-services/src/lib/directives/node-restore.directive.ts)
|
||||||
|
|
||||||
|
|
||||||
## Renamed items
|
## Renamed items
|
||||||
|
|
||||||
|
@ -18,11 +18,12 @@
|
|||||||
import { MinimalNode } from '@alfresco/js-api';
|
import { MinimalNode } from '@alfresco/js-api';
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { TestBed } from '@angular/core/testing';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { AlfrescoApiService, CardViewUpdateService, NodesApiService, setupTestBed } from '@alfresco/adf-core';
|
import { AlfrescoApiService, NodesApiService, setupTestBed } from '@alfresco/adf-core';
|
||||||
import { EMPTY, of } from 'rxjs';
|
import { EMPTY, of } from 'rxjs';
|
||||||
import { ContentTestingModule } from '../../testing/content.testing.module';
|
import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||||
import { NodeAspectService } from './node-aspect.service';
|
import { NodeAspectService } from './node-aspect.service';
|
||||||
import { DialogAspectListService } from './dialog-aspect-list.service';
|
import { DialogAspectListService } from './dialog-aspect-list.service';
|
||||||
|
import { CardViewContentUpdateService } from '../../services/card-view-content-update.service';
|
||||||
|
|
||||||
describe('NodeAspectService', () => {
|
describe('NodeAspectService', () => {
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ describe('NodeAspectService', () => {
|
|||||||
let nodeAspectService: NodeAspectService;
|
let nodeAspectService: NodeAspectService;
|
||||||
let nodeApiService: NodesApiService;
|
let nodeApiService: NodesApiService;
|
||||||
let alfrescoApiService: AlfrescoApiService;
|
let alfrescoApiService: AlfrescoApiService;
|
||||||
let cardViewUpdateService: CardViewUpdateService;
|
let cardViewContentUpdateService: CardViewContentUpdateService;
|
||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [
|
imports: [
|
||||||
@ -44,7 +45,7 @@ describe('NodeAspectService', () => {
|
|||||||
nodeAspectService = TestBed.inject(NodeAspectService);
|
nodeAspectService = TestBed.inject(NodeAspectService);
|
||||||
nodeApiService = TestBed.inject(NodesApiService);
|
nodeApiService = TestBed.inject(NodesApiService);
|
||||||
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
||||||
cardViewUpdateService = TestBed.inject(CardViewUpdateService);
|
cardViewContentUpdateService = TestBed.inject(CardViewContentUpdateService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call openAspectListDialog with correct parameters when selectorAutoFocusedOnClose is passed', () => {
|
it('should call openAspectListDialog with correct parameters when selectorAutoFocusedOnClose is passed', () => {
|
||||||
@ -89,7 +90,7 @@ describe('NodeAspectService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should send and update node aspect once the node has been updated', async () => {
|
it('should send and update node aspect once the node has been updated', async () => {
|
||||||
await cardViewUpdateService.updatedAspect$.subscribe((nodeUpdated) => {
|
await cardViewContentUpdateService.updatedAspect$.subscribe((nodeUpdated) => {
|
||||||
expect(nodeUpdated.id).toBe('fake-node-id');
|
expect(nodeUpdated.id).toBe('fake-node-id');
|
||||||
expect(nodeUpdated.aspectNames).toEqual(['a', 'b', 'c']);
|
expect(nodeUpdated.aspectNames).toEqual(['a', 'b', 'c']);
|
||||||
});
|
});
|
||||||
|
@ -16,8 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { AlfrescoApiService, CardViewUpdateService, NodesApiService } from '@alfresco/adf-core';
|
import { AlfrescoApiService, NodesApiService } from '@alfresco/adf-core';
|
||||||
import { DialogAspectListService } from './dialog-aspect-list.service';
|
import { DialogAspectListService } from './dialog-aspect-list.service';
|
||||||
|
import { CardViewContentUpdateService } from '../../services/card-view-content-update.service';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -27,14 +28,14 @@ export class NodeAspectService {
|
|||||||
constructor(private alfrescoApiService: AlfrescoApiService,
|
constructor(private alfrescoApiService: AlfrescoApiService,
|
||||||
private nodesApiService: NodesApiService,
|
private nodesApiService: NodesApiService,
|
||||||
private dialogAspectListService: DialogAspectListService,
|
private dialogAspectListService: DialogAspectListService,
|
||||||
private cardViewUpdateService: CardViewUpdateService) {
|
private cardViewContentUpdateService: CardViewContentUpdateService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateNodeAspects(nodeId: string, selectorAutoFocusedOnClose?: string) {
|
updateNodeAspects(nodeId: string, selectorAutoFocusedOnClose?: string) {
|
||||||
this.dialogAspectListService.openAspectListDialog(nodeId, selectorAutoFocusedOnClose).subscribe((aspectList) => {
|
this.dialogAspectListService.openAspectListDialog(nodeId, selectorAutoFocusedOnClose).subscribe((aspectList) => {
|
||||||
this.nodesApiService.updateNode(nodeId, { aspectNames: [...aspectList] }).subscribe((updatedNode) => {
|
this.nodesApiService.updateNode(nodeId, { aspectNames: [...aspectList] }).subscribe((updatedNode) => {
|
||||||
this.alfrescoApiService.nodeUpdated.next(updatedNode);
|
this.alfrescoApiService.nodeUpdated.next(updatedNode);
|
||||||
this.cardViewUpdateService.updateNodeAspect(updatedNode);
|
this.cardViewContentUpdateService.updateNodeAspect(updatedNode);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -22,19 +22,20 @@ import { MinimalNode, Node } from '@alfresco/js-api';
|
|||||||
import { ContentMetadataComponent } from './content-metadata.component';
|
import { ContentMetadataComponent } from './content-metadata.component';
|
||||||
import { ContentMetadataService } from '../../services/content-metadata.service';
|
import { ContentMetadataService } from '../../services/content-metadata.service';
|
||||||
import {
|
import {
|
||||||
CardViewBaseItemModel, CardViewComponent, CardViewUpdateService, NodesApiService,
|
CardViewBaseItemModel, CardViewComponent, NodesApiService,
|
||||||
LogService, setupTestBed
|
LogService, setupTestBed
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { throwError, of } from 'rxjs';
|
import { throwError, of } from 'rxjs';
|
||||||
import { ContentTestingModule } from '../../../testing/content.testing.module';
|
import { ContentTestingModule } from '../../../testing/content.testing.module';
|
||||||
import { mockGroupProperties } from './mock-data';
|
import { mockGroupProperties } from './mock-data';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { CardViewContentUpdateService } from '../../../services/card-view-content-update.service';
|
||||||
|
|
||||||
describe('ContentMetadataComponent', () => {
|
describe('ContentMetadataComponent', () => {
|
||||||
let component: ContentMetadataComponent;
|
let component: ContentMetadataComponent;
|
||||||
let fixture: ComponentFixture<ContentMetadataComponent>;
|
let fixture: ComponentFixture<ContentMetadataComponent>;
|
||||||
let contentMetadataService: ContentMetadataService;
|
let contentMetadataService: ContentMetadataService;
|
||||||
let updateService: CardViewUpdateService;
|
let updateService: CardViewContentUpdateService;
|
||||||
let nodesApiService: NodesApiService;
|
let nodesApiService: NodesApiService;
|
||||||
let node: Node;
|
let node: Node;
|
||||||
let folderNode: Node;
|
let folderNode: Node;
|
||||||
@ -52,7 +53,7 @@ describe('ContentMetadataComponent', () => {
|
|||||||
fixture = TestBed.createComponent(ContentMetadataComponent);
|
fixture = TestBed.createComponent(ContentMetadataComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
contentMetadataService = TestBed.inject(ContentMetadataService);
|
contentMetadataService = TestBed.inject(ContentMetadataService);
|
||||||
updateService = TestBed.inject(CardViewUpdateService);
|
updateService = TestBed.inject(CardViewContentUpdateService);
|
||||||
nodesApiService = TestBed.inject(NodesApiService);
|
nodesApiService = TestBed.inject(NodesApiService);
|
||||||
|
|
||||||
node = {
|
node = {
|
||||||
|
@ -22,7 +22,6 @@ import {
|
|||||||
CardViewItem,
|
CardViewItem,
|
||||||
NodesApiService,
|
NodesApiService,
|
||||||
LogService,
|
LogService,
|
||||||
CardViewUpdateService,
|
|
||||||
AlfrescoApiService,
|
AlfrescoApiService,
|
||||||
TranslationService,
|
TranslationService,
|
||||||
AppConfigService,
|
AppConfigService,
|
||||||
@ -32,6 +31,7 @@ import {
|
|||||||
import { ContentMetadataService } from '../../services/content-metadata.service';
|
import { ContentMetadataService } from '../../services/content-metadata.service';
|
||||||
import { CardViewGroup, PresetConfig } from '../../interfaces/content-metadata.interfaces';
|
import { CardViewGroup, PresetConfig } from '../../interfaces/content-metadata.interfaces';
|
||||||
import { takeUntil, debounceTime, catchError, map } from 'rxjs/operators';
|
import { takeUntil, debounceTime, catchError, map } from 'rxjs/operators';
|
||||||
|
import { CardViewContentUpdateService } from '../../../services/card-view-content-update.service';
|
||||||
|
|
||||||
const DEFAULT_SEPARATOR = ', ';
|
const DEFAULT_SEPARATOR = ', ';
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private contentMetadataService: ContentMetadataService,
|
private contentMetadataService: ContentMetadataService,
|
||||||
private cardViewUpdateService: CardViewUpdateService,
|
private cardViewContentUpdateService: CardViewContentUpdateService,
|
||||||
private nodesApiService: NodesApiService,
|
private nodesApiService: NodesApiService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private alfrescoApiService: AlfrescoApiService,
|
private alfrescoApiService: AlfrescoApiService,
|
||||||
@ -110,7 +110,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.cardViewUpdateService.itemUpdated$
|
this.cardViewContentUpdateService.itemUpdated$
|
||||||
.pipe(
|
.pipe(
|
||||||
debounceTime(500),
|
debounceTime(500),
|
||||||
takeUntil(this.onDestroy$))
|
takeUntil(this.onDestroy$))
|
||||||
@ -122,7 +122,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
this.cardViewUpdateService.updatedAspect$.pipe(
|
this.cardViewContentUpdateService.updatedAspect$.pipe(
|
||||||
debounceTime(500),
|
debounceTime(500),
|
||||||
takeUntil(this.onDestroy$))
|
takeUntil(this.onDestroy$))
|
||||||
.subscribe((node) => this.loadProperties(node));
|
.subscribe((node) => this.loadProperties(node));
|
||||||
@ -201,14 +201,14 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
private updateNode() {
|
private updateNode() {
|
||||||
this.nodesApiService.updateNode(this.node.id, this.changedProperties).pipe(
|
this.nodesApiService.updateNode(this.node.id, this.changedProperties).pipe(
|
||||||
catchError((err) => {
|
catchError((err) => {
|
||||||
this.cardViewUpdateService.updateElement(this.targetProperty);
|
this.cardViewContentUpdateService.updateElement(this.targetProperty);
|
||||||
this.handleUpdateError(err);
|
this.handleUpdateError(err);
|
||||||
return of(null);
|
return of(null);
|
||||||
}))
|
}))
|
||||||
.subscribe((updatedNode) => {
|
.subscribe((updatedNode) => {
|
||||||
if (updatedNode) {
|
if (updatedNode) {
|
||||||
if (this.hasContentTypeChanged(this.changedProperties)) {
|
if (this.hasContentTypeChanged(this.changedProperties)) {
|
||||||
this.cardViewUpdateService.updateNodeAspect(this.node);
|
this.cardViewContentUpdateService.updateNodeAspect(this.node);
|
||||||
}
|
}
|
||||||
this.revertChanges();
|
this.revertChanges();
|
||||||
Object.assign(this.node, updatedNode);
|
Object.assign(this.node, updatedNode);
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Alfresco Software, Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { CardViewBaseItemModel, UpdateNotification } from '@alfresco/adf-core';
|
||||||
|
import { MinimalNode } from '@alfresco/js-api';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
|
||||||
|
export interface BaseCardViewContentUpdate {
|
||||||
|
itemUpdated$: Subject<UpdateNotification>;
|
||||||
|
updatedAspect$: Subject<MinimalNode>;
|
||||||
|
|
||||||
|
update(property: CardViewBaseItemModel, newValue: any);
|
||||||
|
updateElement(notification: CardViewBaseItemModel);
|
||||||
|
updateNodeAspect(node: MinimalNode);
|
||||||
|
}
|
@ -20,4 +20,5 @@ export * from './library-entity.interface';
|
|||||||
export * from './restore-message-model.interface';
|
export * from './restore-message-model.interface';
|
||||||
export * from './library-membership-error-event.interface';
|
export * from './library-membership-error-event.interface';
|
||||||
export * from './library-membership-toggle-event.interface';
|
export * from './library-membership-toggle-event.interface';
|
||||||
|
export * from './base-card-view-content-update.interface';
|
||||||
|
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Alfresco Software, Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { MinimalNode } from '@alfresco/js-api';
|
||||||
|
import { fakeAsync, TestBed } from '@angular/core/testing';
|
||||||
|
import { CardViewContentUpdateService } from './card-view-content-update.service';
|
||||||
|
|
||||||
|
describe('CardViewContentUpdateService', () => {
|
||||||
|
|
||||||
|
let cardViewContentUpdateService: CardViewContentUpdateService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
cardViewContentUpdateService = TestBed.inject(CardViewContentUpdateService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should send updated node when aspect changed', fakeAsync(() => {
|
||||||
|
const fakeNode: MinimalNode = { id: 'Bigfoot'} as MinimalNode;
|
||||||
|
cardViewContentUpdateService.updatedAspect$.subscribe((node: MinimalNode) => {
|
||||||
|
expect(node.id).toBe('Bigfoot');
|
||||||
|
});
|
||||||
|
|
||||||
|
cardViewContentUpdateService.updateNodeAspect(fakeNode);
|
||||||
|
}));
|
||||||
|
});
|
@ -0,0 +1,58 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Alfresco Software, Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { UpdateNotification, CardViewBaseItemModel, CardViewUpdateService } from '@alfresco/adf-core';
|
||||||
|
import { MinimalNode } from '@alfresco/js-api';
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
import { BaseCardViewContentUpdate } from '../interfaces/base-card-view-content-update.interface';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class CardViewContentUpdateService implements BaseCardViewContentUpdate {
|
||||||
|
|
||||||
|
itemUpdated$ = new Subject<UpdateNotification>();
|
||||||
|
|
||||||
|
updatedAspect$ = new Subject<MinimalNode>();
|
||||||
|
|
||||||
|
constructor(private cardViewUpdateService: CardViewUpdateService) {
|
||||||
|
this.linkVariables();
|
||||||
|
}
|
||||||
|
|
||||||
|
update(property: CardViewBaseItemModel, newValue: any) {
|
||||||
|
this.cardViewUpdateService.update(property, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateElement(notification: CardViewBaseItemModel) {
|
||||||
|
this.cardViewUpdateService.updateElement(notification);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateNodeAspect(node: MinimalNode) {
|
||||||
|
this.updatedAspect$.next(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
private linkVariables() {
|
||||||
|
this.linkItemUpdated();
|
||||||
|
}
|
||||||
|
|
||||||
|
private linkItemUpdated() {
|
||||||
|
this.cardViewUpdateService.itemUpdated$.subscribe(res => {
|
||||||
|
this.itemUpdated$.next(res);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
18
lib/content-services/src/lib/services/index.ts
Normal file
18
lib/content-services/src/lib/services/index.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Alfresco Software, Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export * from './public-api';
|
18
lib/content-services/src/lib/services/public-api.ts
Normal file
18
lib/content-services/src/lib/services/public-api.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Alfresco Software, Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export * from './card-view-content-update.service';
|
@ -38,5 +38,6 @@ export * from './lib/content-type/index';
|
|||||||
export * from './lib/new-version-uploader';
|
export * from './lib/new-version-uploader';
|
||||||
export * from './lib/interfaces/index';
|
export * from './lib/interfaces/index';
|
||||||
export * from './lib/version-compatibility/index';
|
export * from './lib/version-compatibility/index';
|
||||||
|
export * from './lib/services/index';
|
||||||
|
|
||||||
export * from './lib/content.module';
|
export * from './lib/content.module';
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
6.0.0-beta.1
|
|
||||||
- CheckAllowableOperationDirective: Moved from ADF Core to ADF content services
|
|
||||||
- LibraryFavoriteDirective: Moved from ADF Core to ADF content services
|
|
||||||
- LibraryMembershipDirective: Moved from ADF Core to ADF content services
|
|
||||||
- NodeDeleteDirective: Moved from ADF Core to ADF content services
|
|
||||||
- NodeFavoriteDirective: Moved from ADF Core to ADF content services
|
|
||||||
- NodeRestoreDirective: Moved from ADF Core to ADF content services
|
|
||||||
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
ComponentFactoryResolver,
|
|
||||||
Input,
|
Input,
|
||||||
OnChanges,
|
OnChanges,
|
||||||
SimpleChange,
|
SimpleChange,
|
||||||
@ -67,8 +66,7 @@ export class CardViewItemDispatcherComponent implements OnChanges {
|
|||||||
public ngOnInit;
|
public ngOnInit;
|
||||||
public ngDoCheck;
|
public ngDoCheck;
|
||||||
|
|
||||||
constructor(private cardItemTypeService: CardItemTypeService,
|
constructor(private cardItemTypeService: CardItemTypeService) {
|
||||||
private resolver: ComponentFactoryResolver) {
|
|
||||||
const dynamicLifeCycleMethods = [
|
const dynamicLifeCycleMethods = [
|
||||||
'ngOnInit',
|
'ngOnInit',
|
||||||
'ngDoCheck',
|
'ngDoCheck',
|
||||||
@ -102,8 +100,7 @@ export class CardViewItemDispatcherComponent implements OnChanges {
|
|||||||
private loadComponent() {
|
private loadComponent() {
|
||||||
const factoryClass = this.cardItemTypeService.resolveComponentType(this.property);
|
const factoryClass = this.cardItemTypeService.resolveComponentType(this.property);
|
||||||
|
|
||||||
const factory = this.resolver.resolveComponentFactory(factoryClass);
|
this.componentReference = this.content.viewContainerRef.createComponent(factoryClass);
|
||||||
this.componentReference = this.content.viewContainerRef.createComponent(factory);
|
|
||||||
|
|
||||||
this.componentReference.instance.editable = this.editable;
|
this.componentReference.instance.editable = this.editable;
|
||||||
this.componentReference.instance.property = this.property;
|
this.componentReference.instance.property = this.property;
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Alfresco Software, Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
import { CardViewBaseItemModel } from '../models/card-view-baseitem.model';
|
||||||
|
import { UpdateNotification } from './update-notification.interface';
|
||||||
|
import { ClickNotification } from './click-notification.interface';
|
||||||
|
|
||||||
|
export interface BaseCardViewUpdate {
|
||||||
|
itemUpdated$: Subject<UpdateNotification>;
|
||||||
|
itemClicked$: Subject<ClickNotification>;
|
||||||
|
updateItem$: Subject<CardViewBaseItemModel>;
|
||||||
|
|
||||||
|
update(property: CardViewBaseItemModel, newValue: any);
|
||||||
|
clicked(property: CardViewBaseItemModel);
|
||||||
|
updateElement(notification: CardViewBaseItemModel);
|
||||||
|
}
|
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { CardViewItemValidator } from './card-view-item-validator.interface';
|
import { CardViewItemValidator } from './card-view-item-validator.interface';
|
||||||
import { Constraint } from '@alfresco/js-api';
|
|
||||||
|
|
||||||
export interface CardViewItemProperties {
|
export interface CardViewItemProperties {
|
||||||
label: string;
|
label: string;
|
||||||
@ -29,6 +28,12 @@ export interface CardViewItemProperties {
|
|||||||
hint?: string;
|
hint?: string;
|
||||||
validators?: CardViewItemValidator[];
|
validators?: CardViewItemValidator[];
|
||||||
data?: any;
|
data?: any;
|
||||||
constraints?: Constraint[];
|
constraints?: Array<{
|
||||||
|
id: string;
|
||||||
|
type?: string;
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
|
parameters?: { [key: string]: any };
|
||||||
|
}>;
|
||||||
multivalued?: boolean;
|
multivalued?: boolean;
|
||||||
}
|
}
|
||||||
|
@ -24,3 +24,6 @@ export * from './card-view-boolitem-properties.interface';
|
|||||||
export * from './card-view-textitem-pipe-property.interface';
|
export * from './card-view-textitem-pipe-property.interface';
|
||||||
export * from './card-view-keyvaluepairsitem-properties.interface';
|
export * from './card-view-keyvaluepairsitem-properties.interface';
|
||||||
export * from './card-view-selectitem-properties.interface';
|
export * from './card-view-selectitem-properties.interface';
|
||||||
|
export * from './base-card-view-update.interface';
|
||||||
|
export * from './click-notification.interface';
|
||||||
|
export * from './update-notification.interface';
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Alfresco Software, Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export interface ClickNotification {
|
||||||
|
target: any;
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Alfresco Software, Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { CardViewBaseItemModel } from '../models/card-view-baseitem.model';
|
||||||
|
|
||||||
|
export interface UpdateNotification {
|
||||||
|
target: CardViewBaseItemModel;
|
||||||
|
changed: any;
|
||||||
|
}
|
@ -15,7 +15,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { MinimalNode } from '@alfresco/js-api';
|
|
||||||
import { fakeAsync, TestBed } from '@angular/core/testing';
|
import { fakeAsync, TestBed } from '@angular/core/testing';
|
||||||
import { CardViewBaseItemModel } from '../models/card-view-baseitem.model';
|
import { CardViewBaseItemModel } from '../models/card-view-baseitem.model';
|
||||||
import { CardViewUpdateService, transformKeyToObject } from './card-view-update.service';
|
import { CardViewUpdateService, transformKeyToObject } from './card-view-update.service';
|
||||||
@ -83,13 +82,5 @@ describe('CardViewUpdateService', () => {
|
|||||||
);
|
);
|
||||||
cardViewUpdateService.clicked(property);
|
cardViewUpdateService.clicked(property);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should send updated node when aspect changed', fakeAsync(() => {
|
|
||||||
const fakeNode: MinimalNode = { id: 'Bigfoot'} as MinimalNode;
|
|
||||||
cardViewUpdateService.updatedAspect$.subscribe((node: MinimalNode) => {
|
|
||||||
expect(node.id).toBe('Bigfoot');
|
|
||||||
});
|
|
||||||
cardViewUpdateService.updateNodeAspect(fakeNode);
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -15,20 +15,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { MinimalNode } from '@alfresco/js-api';
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
|
import { BaseCardViewUpdate } from '../interfaces/base-card-view-update.interface';
|
||||||
|
import { ClickNotification } from '../interfaces/click-notification.interface';
|
||||||
|
import { UpdateNotification } from '../interfaces/update-notification.interface';
|
||||||
import { CardViewBaseItemModel } from '../models/card-view-baseitem.model';
|
import { CardViewBaseItemModel } from '../models/card-view-baseitem.model';
|
||||||
|
|
||||||
export interface UpdateNotification {
|
|
||||||
target: CardViewBaseItemModel;
|
|
||||||
changed: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ClickNotification {
|
|
||||||
target: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const transformKeyToObject = (key: string, value): any => {
|
export const transformKeyToObject = (key: string, value): any => {
|
||||||
const objectLevels: string[] = key.split('.').reverse();
|
const objectLevels: string[] = key.split('.').reverse();
|
||||||
|
|
||||||
@ -38,12 +31,11 @@ export const transformKeyToObject = (key: string, value): any => {
|
|||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class CardViewUpdateService {
|
export class CardViewUpdateService implements BaseCardViewUpdate {
|
||||||
|
|
||||||
itemUpdated$ = new Subject<UpdateNotification>();
|
itemUpdated$ = new Subject<UpdateNotification>();
|
||||||
itemClicked$ = new Subject<ClickNotification>();
|
itemClicked$ = new Subject<ClickNotification>();
|
||||||
updateItem$ = new Subject<CardViewBaseItemModel>();
|
updateItem$ = new Subject<CardViewBaseItemModel>();
|
||||||
updatedAspect$ = new Subject<MinimalNode>();
|
|
||||||
|
|
||||||
update(property: CardViewBaseItemModel, newValue: any) {
|
update(property: CardViewBaseItemModel, newValue: any) {
|
||||||
this.itemUpdated$.next({
|
this.itemUpdated$.next({
|
||||||
@ -67,8 +59,4 @@ export class CardViewUpdateService {
|
|||||||
this.updateItem$.next(notification);
|
this.updateItem$.next(notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateNodeAspect(node: MinimalNode) {
|
|
||||||
this.updatedAspect$.next(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user