mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +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:
@@ -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 {
|
||||
Component,
|
||||
ComponentFactoryResolver,
|
||||
Input,
|
||||
OnChanges,
|
||||
SimpleChange,
|
||||
@@ -67,8 +66,7 @@ export class CardViewItemDispatcherComponent implements OnChanges {
|
||||
public ngOnInit;
|
||||
public ngDoCheck;
|
||||
|
||||
constructor(private cardItemTypeService: CardItemTypeService,
|
||||
private resolver: ComponentFactoryResolver) {
|
||||
constructor(private cardItemTypeService: CardItemTypeService) {
|
||||
const dynamicLifeCycleMethods = [
|
||||
'ngOnInit',
|
||||
'ngDoCheck',
|
||||
@@ -102,8 +100,7 @@ export class CardViewItemDispatcherComponent implements OnChanges {
|
||||
private loadComponent() {
|
||||
const factoryClass = this.cardItemTypeService.resolveComponentType(this.property);
|
||||
|
||||
const factory = this.resolver.resolveComponentFactory(factoryClass);
|
||||
this.componentReference = this.content.viewContainerRef.createComponent(factory);
|
||||
this.componentReference = this.content.viewContainerRef.createComponent(factoryClass);
|
||||
|
||||
this.componentReference.instance.editable = this.editable;
|
||||
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 { Constraint } from '@alfresco/js-api';
|
||||
|
||||
export interface CardViewItemProperties {
|
||||
label: string;
|
||||
@@ -29,6 +28,12 @@ export interface CardViewItemProperties {
|
||||
hint?: string;
|
||||
validators?: CardViewItemValidator[];
|
||||
data?: any;
|
||||
constraints?: Constraint[];
|
||||
constraints?: Array<{
|
||||
id: string;
|
||||
type?: string;
|
||||
title?: string;
|
||||
description?: string;
|
||||
parameters?: { [key: string]: any };
|
||||
}>;
|
||||
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-keyvaluepairsitem-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.
|
||||
*/
|
||||
|
||||
import { MinimalNode } from '@alfresco/js-api';
|
||||
import { fakeAsync, TestBed } from '@angular/core/testing';
|
||||
import { CardViewBaseItemModel } from '../models/card-view-baseitem.model';
|
||||
import { CardViewUpdateService, transformKeyToObject } from './card-view-update.service';
|
||||
@@ -83,13 +82,5 @@ describe('CardViewUpdateService', () => {
|
||||
);
|
||||
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.
|
||||
*/
|
||||
|
||||
import { MinimalNode } from '@alfresco/js-api';
|
||||
import { Injectable } from '@angular/core';
|
||||
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';
|
||||
|
||||
export interface UpdateNotification {
|
||||
target: CardViewBaseItemModel;
|
||||
changed: any;
|
||||
}
|
||||
|
||||
export interface ClickNotification {
|
||||
target: any;
|
||||
}
|
||||
|
||||
export const transformKeyToObject = (key: string, value): any => {
|
||||
const objectLevels: string[] = key.split('.').reverse();
|
||||
|
||||
@@ -38,12 +31,11 @@ export const transformKeyToObject = (key: string, value): any => {
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class CardViewUpdateService {
|
||||
export class CardViewUpdateService implements BaseCardViewUpdate {
|
||||
|
||||
itemUpdated$ = new Subject<UpdateNotification>();
|
||||
itemClicked$ = new Subject<ClickNotification>();
|
||||
updateItem$ = new Subject<CardViewBaseItemModel>();
|
||||
updatedAspect$ = new Subject<MinimalNode>();
|
||||
|
||||
update(property: CardViewBaseItemModel, newValue: any) {
|
||||
this.itemUpdated$.next({
|
||||
@@ -67,8 +59,4 @@ export class CardViewUpdateService {
|
||||
this.updateItem$.next(notification);
|
||||
}
|
||||
|
||||
updateNodeAspect(node: MinimalNode) {
|
||||
this.updatedAspect$.next(node);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user