-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
8363d09
commit 213a73f
Showing
40 changed files
with
1,588 additions
and
427 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
lib/content-services/src/lib/group/services/group.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.