Skip to content

Commit

Permalink
[ACS-5483] group details view general info and list of assigned users (
Browse files Browse the repository at this point in the history
…#9329)

* ACS-5483 Added possibility to load and update group

* ACS-5483 Implemented unsaved changes dialog

* ACS-5483 Removed console log

* ACS-5483 Made dynamic chip list reusable

* ACS-5483 Fix for more than one row chips

* ACS-5483 Fix for pagination

* ACS-5483 Added some fixes

* ACS-5483 Fixed displaying tags for node

* ACS-5483 Renamed css classes

* ACS-5483 Fixed resizing when chips have pagination

* ACS-5483 Clearing code

* ACS-5483 Documentation for dynamic chip list component

* ACS-5483 Documentation for unsaved changes dialog and guard

* ACS-5483 Documentation for group service

* ACS-5483 Unit tests for GroupService

* ACS-5483 Unit tests for dynamic chip list component

* ACS-5483 Changed fdescribe to describe

* ACS-5483 Unit tests for tag node list component

* ACS-5483 Unit tests for unsaved changes dialog component

* ACS-5483 Unit tests for unsaved changes guard

* ACS-5483 Added description field to group models

* ACS-5483 Correction for updating with description

* ACS-5483 Fixed lint issues

* ACS-5483 Addressed PR comments

* ACS-5483 Reduced complexity

* ACS-5483 Reduced complexity

* ACS-5483 Addressed PR comments
  • Loading branch information
AleksanderSklorz committed Feb 15, 2024
1 parent 8363d09 commit 213a73f
Show file tree
Hide file tree
Showing 40 changed files with 1,588 additions and 427 deletions.
4 changes: 4 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ for more information about installing and using the source code.
| [Comments Component](core/components/comments.component.md) | Displays comments from users involved in a specified environment and allows an involved user to add a comment to a environment. | [Source](../lib/core/src/lib/comments/comments.component.ts) |
| [Data Column Component](core/components/data-column.component.md) | Defines column properties for DataTable, Tasklist, Document List and other components. | [Source](../lib/core/src/lib/datatable/data-column/data-column.component.ts) |
| [DataTable component](core/components/datatable.component.md) | Displays data as a table with customizable columns and presentation. | [Source](../lib/core/src/lib/datatable/components/datatable/datatable.component.ts) |
| [Dynamic Chip List component](core/components/dynamic-chip-list.component.md) | This component shows dynamic list of chips which render depending on free space. | [Source](../lib/core/src/lib/dynamic-chip-list/dynamic-chip-list.component.ts) |
| [Empty Content Component](core/components/empty-content.component.md) | Provides a generic "Empty Content" placeholder for components. | [Source](../lib/core/src/lib/templates/empty-content/empty-content.component.ts) |
| [Empty list component](core/components/empty-list.component.md) | Displays a message indicating that a list is empty. | [Source](../lib/core/src/lib/datatable/components/empty-list/empty-list.component.ts) |
| [Error Content Component](core/components/error-content.component.md) | Displays info about a specific error. | [Source](../lib/core/src/lib/templates/error-content/error-content.component.ts) |
Expand Down Expand Up @@ -144,6 +145,7 @@ for more information about installing and using the source code.
| Name | Description | Source link |
| ---- | ----------- | ----------- |
| [Edit JSON Dialog](core/dialogs/edit-json.dialog.md) | Allows a user to preview or edit a JSON content in a dialog. | [Source](../lib/testing/src/lib/core/dialog/edit-json-dialog.ts) |
| [Unsaved Changes Dialog](core/dialogs/unsaved-changes-dialog.component.md) | Dialog which informs about unsaved changes. Allows discard them and proceed or close dialog and stop proceeding. | [Source](../lib/core/src/lib/dialogs/unsaved-changes-dialog/unsaved-changes-dialog.component.ts) |

### Interfaces

Expand Down Expand Up @@ -238,6 +240,7 @@ The model to update the DataTable require the ID of the row you want change and
| [Storage service](core/services/storage.service.md) | Stores items in the form of key-value pairs. | [Source](../lib/core/src/lib/common/services/storage.service.ts) |
| [Thumbnail service](core/services/thumbnail.service.md) | Retrieves an SVG thumbnail image to represent a document type. | [Source](../lib/core/src/lib/common/services/thumbnail.service.ts) |
| [Translation service](core/services/translation.service.md) | Supports localisation. | [Source](../lib/core/src/lib/translation/translation.service.ts) |
| [Unsaved Changes guard](core/services/unsaved-changes.guard.md) | This guard prevents deactivating route if page has any unsaved changes. User needs intentionally discard changes through displayed modal to leave actual route. | [Source](../lib/core/src/lib/dialogs/unsaved-changes-dialog/unsaved-changes.guard.ts) |
| [Upload Service](core/services/upload.service.md) | Provides access to various APIs related to file upload features. | [Source](../lib/content-services/src/lib/common/services/upload.service.ts) |
| [User access service](core/services/user-access.service.md) | Checks the global and application access of a user | [Source](../lib/core/src/lib/auth/services/user-access.service.ts) |
| [User Preferences Service](core/services/user-preferences.service.md) | Stores preferences for the app and for individual components. | [Source](../lib/core/src/lib/common/services/user-preferences.service.ts) |
Expand Down Expand Up @@ -387,6 +390,7 @@ for more information about installing and using the source code.
| [Document Actions service](content-services/services/document-actions.service.md) | Implements the document menu actions for the Document List component. | [Source](../lib/content-services/src/lib/document-list/services/document-actions.service.ts) |
| [Document List service](content-services/services/document-list.service.md) | Implements node operations used by the Document List component. | [Source](../lib/content-services/src/lib/document-list/services/document-list.service.ts) |
| [Folder Actions service](content-services/services/folder-actions.service.md) | Implements the folder menu actions for the Document List component. | [Source](../lib/content-services/src/lib/document-list/services/folder-actions.service.ts) |
| [Group Service](content-services/services/group.service.md) | Manages groups. | [Source](../lib/content-services/src/lib/group/services/group.service.ts) |
| [New Version Uploader service](content-services/services/new-version-uploader.dialog.service.md) | Display a dialog that allows to upload new file version or to manage the current node versions. | [Source](../lib/content-services/src/lib/new-version-uploader/new-version-uploader.service.ts) |
| [Node Comments Service](content-services/services/node-comments.service.md) | Adds and retrieves comments for nodes in Content Services. | [Source](../lib/content-services/src/lib/node-comments/services/node-comments.service.ts) |
| [Node permission dialog service](content-services/services/node-permission-dialog.service.md) | Displays dialogs to let the user set node permissions. | [Source](../lib/content-services/src/lib/permission-manager/services/node-permission-dialog.service.ts) |
Expand Down
6 changes: 5 additions & 1 deletion docs/content-services/components/tag-node-list.component.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Shows tags for a node.

| Name | Type | Description |
| ---- | ---- | ----------- |
| results | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<any>` | Emitted when a tag is selected. |
| results | [`EventEmitter`](https://angular.io/api/core/EventEmitter)[`<TagEntry>`](../../../lib/js-api/src/api/content-rest-api/model/tagEntry.ts)`[]` | Emitted when a tag is selected. |

## Details

Expand All @@ -49,3 +49,7 @@ To limit number of tags initially displayed set `limitTagsDisplayed` to `true`.
```

Now when tag chips will exceed the size of the container number of displayed chips will be limited to as much as fits together with view more button. At least one tag will always be displayed, when one tag and view more button won't fit into one line the button will be displayed under the tag.

## See Also

- [Dynamic Chip List component](../../core/components/dynamic-chip-list.component.md)
25 changes: 25 additions & 0 deletions docs/content-services/services/group.service.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
Title: Group Service
Added: v6.6.0
Status: Active
Last reviewed: 2024-02-07
---

# [Group Service](../../../lib/content-services/src/lib/group/services/group.service.ts "Defined in group.service.ts")

Manages groups.

## Class members

### Methods

- **getGroup**(id: `string`, opts?: [`ContentIncludeQuery`](../../../lib/js-api/src/api/content-rest-api/api/types.ts)): [`Observable`](https://rxjs.dev/guide/observable)`<`[`GroupEntry`](../../../lib/js-api/src/api/content-rest-api/model/groupEntry.ts)`>`<br/>
Returns group for specified id.
- _id:_ `string` - id of group to return.
- _opts:_ [`ContentIncludeQuery`](../../../lib/js-api/src/api/content-rest-api/api/types.ts) - additional query parameters.
- **Returns** [`Observable`](https://rxjs.dev/guide/observable)`<`[`GroupEntry`](../../../lib/js-api/src/api/content-rest-api/model/groupEntry.ts)`>` - group for specified id.
- **updateGroup**(group: [`Group`](../../../lib/js-api/src/api/content-rest-api/docs/Group.md), opts?: [`ContentIncludeQuery`](../../../lib/js-api/src/api/content-rest-api/api/types.ts)): [`Observable`](https://rxjs.dev/guide/observable)`<`[`GroupEntry`](../../../lib/js-api/src/api/content-rest-api/model/groupEntry.ts)`>`<br/>
Updates specified group.
- _group:_ [`Group`](../../../lib/js-api/src/api/content-rest-api/docs/Group.md) - group to update.
- _opts:_ [`ContentIncludeQuery`](../../../lib/js-api/src/api/content-rest-api/api/types.ts) - additional query parameters.
- **Returns** [`Observable`](https://rxjs.dev/guide/observable)`<`[`GroupEntry`](../../../lib/js-api/src/api/content-rest-api/model/groupEntry.ts)`>` - updated group.
57 changes: 57 additions & 0 deletions docs/core/components/dynamic-chip-list.component.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
Title: Dynamic Chip List component
Added: v6.6.0
Status: Active
Last reviewed: 2024-02-06
---

# [Dynamic Chip List component](../../../lib/core/src/lib/dynamic-chip-list/dynamic-chip-list.component.ts "Defined in dynamic-chip-list.component.ts")

This component shows dynamic list of chips which render depending on free space.

![List of chips](../../docassets/images/dynamic-chip-list.png)

## Basic Usage

```html
<adf-dynamic-chip-list
[chips]="chips"
[limitChipsDisplayed]="true"
[showDelete]="true"
(displayNext)="onDisplayNext()"
(removedChip)="onRemovedChip($event)">
</adf-dynamic-chip-list>
```

## Class members

### Properties

| Name | Type | Default value | Description |
|---------------------|---------------------------------------------------------------------------------|---------------|---------------------------------------------|
| limitChipsDisplayed | `boolean` | false | Should limit number of chips displayed. |
| showDelete | `boolean` | true | Show delete button. |
| pagination | [`Pagination`](../../../lib/js-api/src/api/content-rest-api/docs/Pagination.md) | | Provide if you want to use paginated chips. |
| chips | [`Chip`](../../../lib/core/src/lib/dynamic-chip-list/chip.ts)`[]` | | List of chips to display. |

### Events

| Name | Type | Description |
|-------------|----------------------------------------------------------------------|-----------------------------------------------|
| displayNext | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<void>` | Emitted when button for view more is clicked. |
| removedChip | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<string>` | Emitted when any chip is removed. |

## Details

### Limit number of chips displayed initially

To limit number of chips initially displayed set `limitChipsDisplayed` to `true`.

```html
<adf-dynamic-chip-list
[chips]="chips"
[limitChipsDisplayed]="true">
</adf-dynamic-chip-list>
```

Now when chips will exceed the size of the container number of displayed chips will be limited to as much as fits together with view more button. At least one chip will always be displayed, when one chip and view more button won't fit into one line the button will be displayed under the chip.
27 changes: 27 additions & 0 deletions docs/core/dialogs/unsaved-changes-dialog.component.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
Title: Unsaved Changes Dialog component
Added: v6.6.0
Status: Active
Last reviewed: 2024-02-06
---

# [Unsaved Changes Dialog component](../../../lib/core/src/lib/dialogs/unsaved-changes-dialog/unsaved-changes-dialog.component.ts "Defined in unsaved-changes-dialog.component.ts")

Dialog which informs about unsaved changes. Allows discard them and proceed or close dialog and stop proceeding.

![Unsaved Changes Dialog](../../docassets/images/unsaved-changes-dialog.png)

## Basic Usage

```ts
this.dialog.open(UnsavedChangesDialogComponent);
```
## Details

### Detecting if changes should be discarded.

To detect if changes should be discarded you need to check value passed on dialog's close. If value is true then changes should be discard, false otherwise.

## See also

- [Unsaved Changes guard](../services/unsaved-changes.guard.md)
22 changes: 22 additions & 0 deletions docs/core/services/unsaved-changes.guard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
Title: Unsaved Changes guard
Added: v6.6.0
Status: Active
Last reviewed: 2024-02-06
---

# [Unsaved Changes guard](../../../lib/core/src/lib/dialogs/unsaved-changes-dialog/unsaved-changes.guard.ts "Defined in unsaved-changes.guard.ts")

This guard prevents deactivating route if page has any unsaved changes. User needs intentionally discard changes through displayed modal to leave actual route.

## Class members

### Methods

- **canDeactivate**(): `boolean` | [`Observable`](https://rxjs.dev/guide/observable)`<boolean>`<br/>
Allows to deactivate route when there is no unsaved changes, otherwise displays dialog to confirm discarding changes.
- **Returns** `boolean` | [`Observable`](https://rxjs.dev/guide/observable)`<boolean>` - true when there is no unsaved changes or changes can be discarded, false otherwise.

## See also

- [Unsaved Changes Dialog component](../dialogs/unsaved-changes-dialog.component.md)
Binary file added docs/docassets/images/dynamic-chip-list.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/docassets/images/unsaved-changes-dialog.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions docs/versionIndex.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ backend services have been tested with each released version of ADF.

## Versions

- [v6.7.0](#v670)
- [v6.4.0](#v640)
- [v6.2.0](#v620)
- [v6.1.0](#v610)
Expand Down Expand Up @@ -44,6 +45,17 @@ backend services have been tested with each released version of ADF.
- [v2.1.0](#v210)
- [v2.0.0](#v200)

## v6.7.0

<!--670 start-->

- [Dynamic Chip List component](core/components/dynamic-chip-list.component.md)
- [Unsaved Changes Dialog component](core/dialogs/unsaved-changes-dialog.component.md)
- [Unsaved Changes guard](core/services/unsaved-changes.guard.md)
- [Group Service](content-services/services/group.service.md)

<!--670 end-->

## v6.4.0

<!--v640 start-->
Expand Down
134 changes: 134 additions & 0 deletions lib/content-services/src/lib/group/services/group.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*!
* @license
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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 { TestBed } from '@angular/core/testing';
import { ContentTestingModule } from '../../testing/content.testing.module';
import { GroupService } from '@alfresco/adf-content-services';
import { ContentIncludeQuery, GroupEntry } from '@alfresco/js-api';

describe('GroupService', () => {
let service: GroupService;
let group: GroupEntry;
let returnedGroup: GroupEntry;
let opts: ContentIncludeQuery;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [ContentTestingModule]
});
service = TestBed.inject(GroupService);
group = {
entry: {
id: 'some id',
displayName: 'some name',
description: 'some description'
}
};
returnedGroup = JSON.parse(JSON.stringify(group));
opts = {
include: ['description']
};
});

describe('getGroup', () => {
it('should return group returned by GroupsApi', (done) => {
spyOn(service.groupsApi, 'getGroup').and.returnValue(Promise.resolve(returnedGroup));

service.getGroup(group.entry.id, opts).subscribe((groupEntry) => {
expect(groupEntry).toBe(returnedGroup);
expect(service.groupsApi.getGroup).toHaveBeenCalledWith(group.entry.id, {
include: ['description']
});
done();
});
});

it('should return group returned by GroupsApi when description is not supplied', (done) => {
returnedGroup.entry.description = undefined;
spyOn(service.groupsApi, 'getGroup').and.returnValue(Promise.resolve(returnedGroup));

service.getGroup(group.entry.id, opts).subscribe((groupEntry) => {
expect(groupEntry).toEqual({
entry: {
id: returnedGroup.entry.id,
displayName: returnedGroup.entry.displayName,
description: ''
}
});
expect(service.groupsApi.getGroup).toHaveBeenCalledWith(group.entry.id, {
include: ['description']
});
done();
});
});
});

describe('updateGroup', () => {
it('should return updated Group', (done) => {
spyOn(service.groupsApi, 'updateGroup').and.returnValue(Promise.resolve(returnedGroup));

service.updateGroup(group.entry, opts).subscribe((groupEntry) => {
expect(groupEntry).toEqual(returnedGroup);
expect(service.groupsApi.updateGroup).toHaveBeenCalledWith(group.entry.id, {
displayName: group.entry.displayName,
description: group.entry.description
}, {
include: ['description']
});
done();
});
});

it('should return updated Group when description is not supplied', (done) => {
returnedGroup.entry.description = undefined;
spyOn(service.groupsApi, 'updateGroup').and.returnValue(Promise.resolve(returnedGroup));

service.updateGroup(group.entry, opts).subscribe((groupEntry) => {
expect(groupEntry).toEqual({
entry: {
id: returnedGroup.entry.id,
displayName: returnedGroup.entry.displayName,
description: ''
}
});
expect(service.groupsApi.updateGroup).toHaveBeenCalledWith(group.entry.id, {
displayName: group.entry.displayName,
description: group.entry.description
}, {
include: ['description']
});
done();
});
});

it('should allow to update only description', (done) => {
spyOn(service.groupsApi, 'updateGroup').and.returnValue(Promise.resolve(returnedGroup));
group.entry.displayName = undefined;

service.updateGroup(group.entry, opts).subscribe((groupEntry) => {
expect(groupEntry).toEqual(returnedGroup);
expect(service.groupsApi.updateGroup).toHaveBeenCalledWith(group.entry.id, {
displayName: group.entry.displayName,
description: group.entry.description
}, {
include: ['description']
});
done();
});
});
});
});

0 comments on commit 213a73f

Please sign in to comment.