diff --git a/docs/README.md b/docs/README.md index 474ae11cfb..b7ee161214 100644 --- a/docs/README.md +++ b/docs/README.md @@ -285,10 +285,8 @@ for more information about installing and using the source code. | [Document List component](content-services/components/document-list.component.md) | Displays the documents from a repository. | [Source](../lib/content-services/src/lib/document-list/components/document-list.component.ts) | | [Dropdown Breadcrumb Component](content-services/components/dropdown-breadcrumb.component.md) | Indicates the current position within a navigation hierarchy using a dropdown menu. | [Source](../lib/content-services/src/lib/breadcrumb/dropdown-breadcrumb.component.ts) | | [File Uploading Dialog Component](content-services/components/file-uploading-dialog.component.md) | Shows a dialog listing all the files uploaded with the Upload Button or Drag Area components. | [Source](../lib/content-services/src/lib/upload/components/file-uploading-dialog.component.ts) | -| [Like component](content-services/components/like.component.md) | Allows a user to add "likes" to an item. | [Source](../lib/content-services/src/lib/social/like.component.ts) | | [Node Comments Component](content-services/components/node-comments.component.md) | Displays comments from users involved in a specified content and allows an involved user to add a comment to a content. | [Source](../lib/content-services/src/lib/node-comments/node-comments.component.ts) | | [Permission List Component](content-services/components/permission-list.component.md) | Shows node permissions as a table. | [Source](../lib/content-services/src/lib/permission-manager/components/permission-list/permission-list.component.ts) | -| [Rating component](content-services/components/rating.component.md) | Allows a user to add and remove rating to an item. | [Source](../lib/content-services/src/lib/social/rating.component.ts) | | [Search check list component](content-services/components/search-check-list.component.md) | Implements a checklist widget for the Search Filter component. | [Source](../lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.ts) | | [Search Chip Input Component](content-services/components/search-chip-input.component.md) | Displays input for providing phrases display as "chips". | [Source](../lib/content-services/src/lib/search/components/search-chip-input/search-chip-input.component.ts) | | [Search Chip Autocomplete Input component](content-services/components/search-chip-autocomplete-input.component.md) | Displays an input with autocomplete options. | [Source](../lib/content-services/src/lib/search/components/search-chip-autocomplete-input/search-chip-autocomplete-input.component.ts) | @@ -395,7 +393,6 @@ for more information about installing and using the source code. | [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) | | [Node Permission service](content-services/services/node-permission.service.md) | Manages role permissions for content nodes. | [Source](../lib/content-services/src/lib/permission-manager/services/node-permission.service.ts) | -| [Rating service](content-services/services/rating.service.md) | Manages ratings for items in Content Services. | [Source](../lib/content-services/src/lib/social/services/rating.service.ts) | | [Search filter service](content-services/services/search-filter.service.md) | Registers widgets for use with the Search Filter component. | [Source](../lib/content-services/src/lib/search/services/search-filter.service.ts) | | [Search Query Builder service](content-services/services/search-query-builder.service.md) | Stores information from all the custom search and faceted search widgets, compiles and runs the final search query. | [Source](../lib/content-services/src/lib/search/services/search-query-builder.service.ts) | | [Security Controls service](content-services/services/security-controls.service.md) | Manages security groups & marks in Content Services. | [Source](../lib/content-services/src/lib/security/services/security-controls-groups-marks-security.service.ts) | diff --git a/docs/content-services/components/like.component.md b/docs/content-services/components/like.component.md deleted file mode 100644 index e38c9e14e1..0000000000 --- a/docs/content-services/components/like.component.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -Title: Like component -Added: v2.0.0 -Status: Active -Last reviewed: 2018-11-14 ---- - -# [Like component](../../../lib/content-services/src/lib/social/like.component.ts "Defined in like.component.ts") - -Allows a user to add "likes" to an item. - -![Custom columns](../../docassets/images/social1.png) - -## Basic Usage - -```html - -``` - -## Class members - -### Properties - -| Name | Type | Default value | Description | -| ---- | ---- | ------------- | ----------- | -| nodeId | `string` | | Identifier of a node to apply likes to. | - -### Events - -| Name | Type | Description | -| ---- | ---- | ----------- | -| changeVote | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when the "vote" gets changed. | - -## See also - -- [Rating component](rating.component.md) -- [Rating service](../services/rating.service.md) diff --git a/docs/content-services/components/rating.component.md b/docs/content-services/components/rating.component.md deleted file mode 100644 index 2481a126e7..0000000000 --- a/docs/content-services/components/rating.component.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -Title: Rating component -Added: v2.0.0 -Status: Active -Last reviewed: 2019-01-14 ---- - -# [Rating component](../../../lib/content-services/src/lib/social/rating.component.ts "Defined in rating.component.ts") - -Allows a user to add and remove rating to an item. - -It displays the average rating and the number of ratings. If the user has not rated the item the average rating stars color is grey. - -![Rating component screenshot](../../docassets/images/social3.png) - -If the user has rated the item the average rating stars color is yellow. - -![Rating component screenshot](../../docassets/images/social2.png) - -In order to remove the rating the user should click on the same star that he rated. -If the average is decimal number it will be rounded. - -## Basic Usage - -```html - - -``` - -## Class members - -### Properties - -| Name | Type | Default value | Description | -| ---- | ---- | ------------- | ----------- | -| nodeId | `string` | | Identifier of the node to apply the rating to. | - -### Events - -| Name | Type | Description | -| ---- | ---- | ----------- | -| changeVote | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when the "vote" gets changed. | - -## See also - -- [Like component](like.component.md) -- [Rating service](../services/rating.service.md) diff --git a/docs/content-services/services/rating.service.md b/docs/content-services/services/rating.service.md deleted file mode 100644 index 2c50ac4828..0000000000 --- a/docs/content-services/services/rating.service.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -Title: Rating service -Added: v2.0.0 -Status: Active -Last reviewed: 2018-05-04 ---- - -# [Rating service](../../../lib/content-services/src/lib/social/services/rating.service.ts "Defined in rating.service.ts") - -Manages ratings for items in Content Services. - -## Class members - -### Methods - -- **deleteRating**(nodeId: `string`, ratingType: `any`): [`Observable`](http://reactivex.io/documentation/observable.html)``
- Removes the current user's rating for a node. - - _nodeId:_ `string` - Target node - - _ratingType:_ `any` - Type of rating to remove (can be "likes" or "fiveStar") - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`` - Null response indicating that the operation is complete -- **getRating**(nodeId: `string`, ratingType: `any`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`RatingEntry`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/content-rest-api/docs/RatingEntry.md)`|any>`
- Gets the current user's rating for a node. - - _nodeId:_ `string` - Node to get the rating from - - _ratingType:_ `any` - Type of rating (can be "likes" or "fiveStar") - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`RatingEntry`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/content-rest-api/docs/RatingEntry.md)`|any>` - The rating value -- **postRating**(nodeId: `string`, ratingType: `string`, vote: `any`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`RatingEntry`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/content-rest-api/docs/RatingEntry.md)`|any>`
- Adds the current user's rating for a node. - - _nodeId:_ `string` - Target node for the rating - - _ratingType:_ `string` - Type of rating (can be "likes" or "fiveStar") - - _vote:_ `any` - Rating value (boolean for "likes", numeric 0..5 for "fiveStar") - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`RatingEntry`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/content-rest-api/docs/RatingEntry.md)`|any>` - Details about the rating, including the new value - -## Details - -The `ratingType` string currently has two possible options, "likes" -and "fiveStar". When the "likes" scheme is used, the result of -`getRating` and the `vote` parameter of `postRating` are boolean -values. When "fiveStar" is used, the value is an integer representing -the number of stars out of five. - -See the [Ratings API](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/RatingsApi.md) -in the Alfresco JS API for more information about the returned data and the -REST API that this service is based on. - -## See also - -- [Like component](../components/like.component.md) -- [Rating component](../components/rating.component.md) diff --git a/lib/content-services/src/lib/content.module.ts b/lib/content-services/src/lib/content.module.ts index d5b9e3db24..e0dc05eef0 100644 --- a/lib/content-services/src/lib/content.module.ts +++ b/lib/content-services/src/lib/content.module.ts @@ -22,7 +22,6 @@ import { CoreModule, SearchTextModule, provideTranslations } from '@alfresco/adf import { MaterialModule } from './material.module'; -import { SocialModule } from './social/social.module'; import { TagModule } from './tag/tag.module'; import { WebScriptModule } from './webscript/webscript.module'; import { DocumentListModule } from './document-list/document-list.module'; @@ -58,7 +57,6 @@ import { ContentAuthLoaderService } from './auth-loader/content-auth-loader.serv imports: [ ContentPipeModule, CoreModule, - SocialModule, TagModule, CommonModule, WebScriptModule, @@ -95,7 +93,6 @@ import { ContentAuthLoaderService } from './auth-loader/content-auth-loader.serv ], exports: [ ContentPipeModule, - SocialModule, TagModule, WebScriptModule, DocumentListModule, diff --git a/lib/content-services/src/lib/social/index.ts b/lib/content-services/src/lib/social/index.ts deleted file mode 100644 index e58e5c1c41..0000000000 --- a/lib/content-services/src/lib/social/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -/*! - * @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. - */ - -export * from './public-api'; diff --git a/lib/content-services/src/lib/social/like.component.html b/lib/content-services/src/lib/social/like.component.html deleted file mode 100644 index e5dee85806..0000000000 --- a/lib/content-services/src/lib/social/like.component.html +++ /dev/null @@ -1,13 +0,0 @@ -
-
- - thumb_up - -
-
-
{{likesCounter}}
-
Like
-
Likes
-
-
diff --git a/lib/content-services/src/lib/social/like.component.scss b/lib/content-services/src/lib/social/like.component.scss deleted file mode 100644 index 9fd1abab35..0000000000 --- a/lib/content-services/src/lib/social/like.component.scss +++ /dev/null @@ -1,34 +0,0 @@ -.adf-like-container { - display: flex; - overflow: hidden; - width: 100%; - align-items: center; - margin-top: 13px; - - .adf-like-counter-container { - display: inherit; - padding: 0 6px; - } - - .adf-left { - padding: 0 6px; - } - - .adf-like-select { - cursor: pointer; - color: #2196f3; - - &:hover { - color: #808080; - } - } - - .adf-like-grey { - cursor: pointer; - color: #808080; - - &:hover { - color: #2196f3; - } - } -} diff --git a/lib/content-services/src/lib/social/like.component.spec.ts b/lib/content-services/src/lib/social/like.component.spec.ts deleted file mode 100644 index e568fb97c5..0000000000 --- a/lib/content-services/src/lib/social/like.component.spec.ts +++ /dev/null @@ -1,92 +0,0 @@ -/*! - * @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 { ComponentFixture, TestBed } from '@angular/core/testing'; -import { LikeComponent } from './like.component'; -import { ContentTestingModule } from '../testing/content.testing.module'; -import { of } from 'rxjs'; -import { RatingService } from './services/rating.service'; - -describe('Like component', () => { - let component: any; - let fixture: ComponentFixture; - let element: HTMLElement; - let service: RatingService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ContentTestingModule] - }); - service = TestBed.inject(RatingService); - - spyOn(service, 'getRating').and.returnValue( - of({ - entry: { - id: 'likes', - aggregate: { numberOfRatings: 2 } - } - }) - ); - - fixture = TestBed.createComponent(LikeComponent); - element = fixture.nativeElement; - component = fixture.componentInstance; - component.nodeId = 'test-id'; - component.ngOnChanges(); - fixture.detectChanges(); - }); - - it('should load the likes by default on onChanges', async () => { - fixture.detectChanges(); - await fixture.whenStable(); - - expect(element.querySelector('#adf-like-counter').innerHTML).toBe('2'); - }); - - it('should increase the number of likes when clicked', async () => { - spyOn(service, 'postRating').and.returnValue( - of({ - entry: { - id: 'likes', - aggregate: { numberOfRatings: 3 } - } - }) - ); - - const likeButton: any = element.querySelector('#adf-like-test-id'); - likeButton.click(); - - fixture.detectChanges(); - await fixture.whenStable(); - - expect(element.querySelector('#adf-like-counter').innerHTML).toBe('3'); - }); - - it('should decrease the number of likes when clicked and is already liked', async () => { - spyOn(service, 'deleteRating').and.returnValue(of('')); - - component.isLike = true; - - const likeButton: any = element.querySelector('#adf-like-test-id'); - likeButton.click(); - - fixture.detectChanges(); - await fixture.whenStable(); - - expect(element.querySelector('#adf-like-counter').innerHTML).toBe('1'); - }); -}); diff --git a/lib/content-services/src/lib/social/like.component.stories.ts b/lib/content-services/src/lib/social/like.component.stories.ts deleted file mode 100644 index 526abc4136..0000000000 --- a/lib/content-services/src/lib/social/like.component.stories.ts +++ /dev/null @@ -1,56 +0,0 @@ -/*! - * @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 { Meta, moduleMetadata, Story } from '@storybook/angular'; -import { RatingService } from './services/rating.service'; -import { LikeComponent } from './like.component'; -import { RatingServiceMock } from './mock/rating.service.mock'; -import { SocialModule } from './social.module'; - -export default { - component: LikeComponent, - title: 'Content Services/Social/Like', - decorators: [ - moduleMetadata({ - imports: [SocialModule], - providers: [ - { provide: RatingService, useClass: RatingServiceMock } - ] - }) - ], - argTypes: { - nodeId: { - control: 'text', - description: 'Identifier of a node to apply likes to.', - defaultValue:'fake-like-node-id', - table: { - type: { summary: 'string' } - } - }, - changeVote: { - action: 'changeVote', - description: 'Emitted when the "vote" gets changed.', - table: { category: 'Actions' } - } - } -} as Meta; - -const template: Story = (args: LikeComponent) => ({ - props: args -}); - -export const like = template.bind({}); diff --git a/lib/content-services/src/lib/social/like.component.ts b/lib/content-services/src/lib/social/like.component.ts deleted file mode 100644 index 5977daaa14..0000000000 --- a/lib/content-services/src/lib/social/like.component.ts +++ /dev/null @@ -1,86 +0,0 @@ -/*! - * @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 { Component, EventEmitter, Input, OnChanges, Output, ViewEncapsulation } from '@angular/core'; -import { RatingService } from './services/rating.service'; -import { RatingEntry } from '@alfresco/js-api'; - -/** - * @deprecated Like component is not used in ACA/ADW/ACC, can be removed. - */ -@Component({ - selector: 'adf-like', - styleUrls: ['./like.component.scss'], - templateUrl: './like.component.html', - encapsulation: ViewEncapsulation.None -}) -export class LikeComponent implements OnChanges { - /** Identifier of a node to apply likes to. */ - @Input() - nodeId: string; - - /** Emitted when the "vote" gets changed. */ - @Output() - changeVote = new EventEmitter(); - - likesCounter: number = 0; - ratingType: string = 'likes'; - isLike: boolean = false; - - constructor(private ratingService: RatingService) { - } - - ngOnChanges() { - this.clean(); - - this.ratingService.getRating(this.nodeId, this.ratingType).subscribe( - (ratingEntry: RatingEntry) => { - if (ratingEntry.entry.aggregate) { - this.likesCounter = ratingEntry.entry.aggregate.numberOfRatings; - if (ratingEntry.entry.ratedAt) { - this.isLike = true; - } - } - } - ); - } - - likeClick() { - if (this.isLike) { - this.ratingService.deleteRating(this.nodeId, this.ratingType).subscribe( - () => { - this.likesCounter -= 1; - this.isLike = false; - this.changeVote.emit(this.likesCounter); - } - ); - } else { - this.ratingService.postRating(this.nodeId, this.ratingType, true).subscribe( - (ratingEntry: RatingEntry) => { - this.likesCounter = ratingEntry.entry.aggregate.numberOfRatings; - this.isLike = true; - this.changeVote.emit(this.likesCounter); - } - ); - } - } - - clean() { - this.isLike = false; - this.likesCounter = 0; - } -} diff --git a/lib/content-services/src/lib/social/mock/rating-response.mock.ts b/lib/content-services/src/lib/social/mock/rating-response.mock.ts deleted file mode 100644 index dbafd0b717..0000000000 --- a/lib/content-services/src/lib/social/mock/rating-response.mock.ts +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * @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. - */ - -export const ratingOneMock = { - entry: { - myRating: '1', - ratedAt: '2017-04-06T14:34:28.061+0000', - id: 'fiveStar', - aggregate: {numberOfRatings: 1, average: 1.0} - } -}; - -export const ratingThreeMock = { - entry: { - myRating: '3', - ratedAt: '2017-04-06T14:36:40.731+0000', - id: 'fiveStar', - aggregate: {numberOfRatings: 1, average: 3.0} - } -}; diff --git a/lib/content-services/src/lib/social/mock/rating.service.mock.ts b/lib/content-services/src/lib/social/mock/rating.service.mock.ts deleted file mode 100644 index 80b688e299..0000000000 --- a/lib/content-services/src/lib/social/mock/rating.service.mock.ts +++ /dev/null @@ -1,60 +0,0 @@ -/*! - * @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 { Injectable } from '@angular/core'; -import { RatingEntry } from '@alfresco/js-api'; -import { Observable, of } from 'rxjs'; -import { ratingOneMock, ratingThreeMock } from './rating-response.mock'; -import { RatingServiceInterface } from '../services/rating.service.interface'; - -@Injectable({ - providedIn: 'root' -}) -export class RatingServiceMock implements RatingServiceInterface { - - getRating(nodeId: string, _ratingType: any): Observable { - if (nodeId === 'fake-like-node-id') { - return of(ratingOneMock); - } - - return of(ratingThreeMock); - } - - postRating(nodeId: string, _ratingType: string, _vote: any): Observable { - if (nodeId === 'ratingOneMock') { - ratingOneMock.entry.aggregate.numberOfRatings = 1; - ratingOneMock.entry.aggregate.average = 1.0; - return of(ratingOneMock); - } - - ratingThreeMock.entry.aggregate.numberOfRatings = 1; - ratingThreeMock.entry.aggregate.average = 1.0; - return of(ratingThreeMock); - } - - deleteRating(nodeId: string, _ratingType: any): Observable { - if (nodeId === 'ratingOneMock') { - ratingOneMock.entry.aggregate.numberOfRatings = 0; - ratingOneMock.entry.aggregate.average = 0; - return of(ratingOneMock); - } - - ratingThreeMock.entry.aggregate.numberOfRatings = 0; - ratingThreeMock.entry.aggregate.average = 0; - return of(ratingThreeMock); - } -} diff --git a/lib/content-services/src/lib/social/public-api.ts b/lib/content-services/src/lib/social/public-api.ts deleted file mode 100644 index 456d1c49f4..0000000000 --- a/lib/content-services/src/lib/social/public-api.ts +++ /dev/null @@ -1,23 +0,0 @@ -/*! - * @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. - */ - -export * from './rating.component'; -export * from './like.component'; - -export * from './services/rating.service'; - -export * from './social.module'; diff --git a/lib/content-services/src/lib/social/rating.component.html b/lib/content-services/src/lib/social/rating.component.html deleted file mode 100644 index a847f9b035..0000000000 --- a/lib/content-services/src/lib/social/rating.component.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - star_rate - - star_border - - - -
-
{{ratingsCounter}}
-
Rating
-
Ratings
-
-
diff --git a/lib/content-services/src/lib/social/rating.component.scss b/lib/content-services/src/lib/social/rating.component.scss deleted file mode 100644 index dba98d712d..0000000000 --- a/lib/content-services/src/lib/social/rating.component.scss +++ /dev/null @@ -1,49 +0,0 @@ -$adf-rated-star-color: #ffe944; -$adf-average-star-color: #808080; - -.adf-rating-container { - display: flex; - overflow: hidden; - width: 100%; - - .adf-rating-counter-container { - display: flex; - align-items: center; - padding: 0 6px; - } - - .adf-rating-left { - padding: 0 6px; - } - - .adf-rating-star { - display: flex; - justify-content: center; - transition: all 0.3s; - cursor: pointer; - width: 25px; - - &:hover { - transform: rotate(13deg) scale(1.2); - } - } - - .adf-colored-star { - color: $adf-rated-star-color; - } - - .adf-colored-star.adf-grey-star, - .adf-colored-star.adf-average-star { - color: $adf-average-star-color; - } -} - -[dir='rtl'] .adf-rating-container { - .adf-rating-star { - transform: rotate(145deg); - } - - .adf-rating-star:hover { - transform: rotate(158deg) scale(1.2); - } -} diff --git a/lib/content-services/src/lib/social/rating.component.spec.ts b/lib/content-services/src/lib/social/rating.component.spec.ts deleted file mode 100644 index 1791d2fedd..0000000000 --- a/lib/content-services/src/lib/social/rating.component.spec.ts +++ /dev/null @@ -1,151 +0,0 @@ -/*! - * @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 { ComponentFixture, TestBed } from '@angular/core/testing'; -import { RatingComponent } from './rating.component'; -import { ContentTestingModule } from '../testing/content.testing.module'; -import { of } from 'rxjs'; -import { RatingService } from './services/rating.service'; - -describe('Rating component', () => { - let component: any; - let fixture: ComponentFixture; - let element: HTMLElement; - let service: RatingService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ContentTestingModule] - }); - fixture = TestBed.createComponent(RatingComponent); - service = TestBed.inject(RatingService); - - element = fixture.nativeElement; - component = fixture.componentInstance; - component.nodeId = 'test-id'; - - fixture.detectChanges(); - }); - - afterEach(() => { - fixture.destroy(); - }); - - describe('Rendering tests', () => { - it('should rating component should be present', async () => { - spyOn(service, 'getRating').and.returnValue( - of({ - entry: { - id: 'fiveStar', - aggregate: { - numberOfRatings: 1, - average: 4 - } - } - }) - ); - - component.ngOnChanges(); - - fixture.detectChanges(); - await fixture.whenStable(); - - expect(element.querySelector('#adf-rating-container')).not.toBe(null); - }); - - it('should the star rating filled with the right grey/colored star', async () => { - spyOn(service, 'getRating').and.returnValue( - of({ - entry: { - myRating: 3, - ratedAt: '2017-04-06T14:34:28.061+0000', - id: 'fiveStar', - aggregate: { numberOfRatings: 1, average: 3.0 } - } - }) - ); - - component.ngOnChanges(); - fixture.detectChanges(); - await fixture.whenStable(); - - expect(element.querySelectorAll('.adf-colored-star').length).toBe(3); - expect(element.querySelectorAll('.adf-grey-star').length).toBe(2); - }); - }); - - it('should click on a star to change your vote', async () => { - spyOn(service, 'getRating').and.returnValue( - of({ - entry: { - myRating: 1, - ratedAt: '2017-04-06T14:34:28.061+0000', - id: 'fiveStar', - aggregate: { numberOfRatings: 1, average: 1.0 } - } - }) - ); - - const rateSpy = spyOn(service, 'postRating').and.returnValue( - of({ - entry: { - myRating: 3, - ratedAt: '2017-04-06T14:36:40.731+0000', - id: 'fiveStar', - aggregate: { numberOfRatings: 1, average: 3.0 } - } - }) - ); - - component.ngOnChanges(); - fixture.detectChanges(); - await fixture.whenStable(); - - expect(element.querySelectorAll('.adf-colored-star').length).toBe(1); - - const starThree: any = element.querySelector('#adf-grey-star-2'); - starThree.click(); - - fixture.detectChanges(); - await fixture.whenStable(); - - expect(rateSpy).toHaveBeenCalled(); - expect(element.querySelectorAll('.adf-colored-star').length).toBe(3); - }); - - it('should click on the rated star to remove your vote', () => { - spyOn(service, 'getRating').and.returnValue( - of({ - entry: { - myRating: 3, - ratedAt: '2017-04-06T14:34:28.061+0000', - id: 'fiveStar', - aggregate: { numberOfRatings: 1, average: 3.0 } - } - }) - ); - - spyOn(service, 'deleteRating').and.returnValue(of({})); - - component.ngOnChanges(); - fixture.detectChanges(); - const starThree: any = element.querySelector('#adf-colored-star-2'); - starThree.click(); - expect(element.querySelectorAll('.adf-colored-star').length).toBe(3); - expect(service.deleteRating).toHaveBeenCalled(); - }); -}); diff --git a/lib/content-services/src/lib/social/rating.component.ts b/lib/content-services/src/lib/social/rating.component.ts deleted file mode 100644 index 426e70a0ab..0000000000 --- a/lib/content-services/src/lib/social/rating.component.ts +++ /dev/null @@ -1,124 +0,0 @@ -/*! - * @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 { Component, EventEmitter, Input, OnChanges, OnDestroy, Output, ViewEncapsulation } from '@angular/core'; -import { RatingService } from './services/rating.service'; -import { RatingEntry } from '@alfresco/js-api'; -import { takeUntil } from 'rxjs/operators'; -import { Subject } from 'rxjs'; - -/** - * @deprecated Rating component is not used in ACA/ADW/ACC, can be removed. - */ -@Component({ - selector: 'adf-rating', - styleUrls: ['./rating.component.scss'], - templateUrl: './rating.component.html', - encapsulation: ViewEncapsulation.None -}) -export class RatingComponent implements OnChanges, OnDestroy { - - /** Identifier of the node to apply the rating to. */ - @Input() - nodeId: string; - - average: number = 0; - - ratingsCounter = 0; - - ratingType: string = 'fiveStar'; - - ratingValue: number; - - /** Emitted when the "vote" gets changed. */ - @Output() - changeVote = new EventEmitter(); - - stars: Array = []; - - onDestroy$ = new Subject(); - - constructor(private ratingService: RatingService) { - } - - ngOnChanges() { - this.ratingService.getRating(this.nodeId, this.ratingType) - .pipe(takeUntil(this.onDestroy$)) - .subscribe( - (ratingEntry: RatingEntry) => { - this.refreshRating(ratingEntry); - } - ); - } - - ngOnDestroy() { - this.onDestroy$.next(true); - this.onDestroy$.complete(); - } - - calculateStars() { - this.stars = []; - const roundedAverage = Math.round(this.average); - - for (let i = 0; i < 5; i++) { - if (i < roundedAverage) { - this.stars.push({fill: true}); - } else { - this.stars.push({fill: false}); - } - } - } - - updateVote(vote: number) { - if (this.ratingValue === vote) { - this.unRateItem(); - } else { - this.rateItem(vote); - } - } - - rateItem(vote: number) { - this.ratingService.postRating(this.nodeId, this.ratingType, vote) - .pipe(takeUntil(this.onDestroy$)) - .subscribe( - (ratingEntry: RatingEntry) => { - this.refreshRating(ratingEntry); - } - ); - } - - unRateItem() { - this.ratingService.deleteRating(this.nodeId, this.ratingType).subscribe( - () => { - this.ratingService.getRating(this.nodeId, this.ratingType) - .pipe(takeUntil(this.onDestroy$)) - .subscribe( - (ratingEntry: RatingEntry) => { - this.refreshRating(ratingEntry); - } - ); - }); - } - - refreshRating(ratingEntry: RatingEntry) { - this.ratingValue = Number.parseFloat(ratingEntry.entry.myRating); - this.average = ratingEntry.entry.aggregate.average; - this.ratingsCounter = ratingEntry.entry.aggregate.numberOfRatings; - this.calculateStars(); - this.changeVote.emit(this.average); - } -} diff --git a/lib/content-services/src/lib/social/services/rating.service.interface.ts b/lib/content-services/src/lib/social/services/rating.service.interface.ts deleted file mode 100644 index 90c662f22c..0000000000 --- a/lib/content-services/src/lib/social/services/rating.service.interface.ts +++ /dev/null @@ -1,26 +0,0 @@ -/*! - * @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 { RatingEntry } from '@alfresco/js-api'; -import { Observable } from 'rxjs'; - -export interface RatingServiceInterface { - - getRating(nodeId: string, ratingType: any): Observable; - postRating(nodeId: string, ratingType: string, vote: any): Observable; - deleteRating(nodeId: string, ratingType: any): Observable; -} diff --git a/lib/content-services/src/lib/social/services/rating.service.spec.ts b/lib/content-services/src/lib/social/services/rating.service.spec.ts deleted file mode 100644 index 0373d1d997..0000000000 --- a/lib/content-services/src/lib/social/services/rating.service.spec.ts +++ /dev/null @@ -1,74 +0,0 @@ -/*! - * @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 { RatingService } from './rating.service'; -import { ContentTestingModule } from '../../testing/content.testing.module'; -import { ratingOneMock, ratingThreeMock } from '../mock/rating-response.mock'; - -declare let jasmine: any; - -describe('Rating service', () => { - let service: RatingService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ContentTestingModule] - }); - service = TestBed.inject(RatingService); - }); - - beforeEach(() => { - jasmine.Ajax.install(); - }); - - afterEach(() => { - jasmine.Ajax.uninstall(); - }); - - it('Should get rating return an Observable', (done) => { - const ratingType: string = 'fiveStar'; - const nodeId: string = 'fake-node-id'; - - service.getRating(nodeId, ratingType).subscribe((data) => { - expect(data.entry.myRating).toBe('1'); - done(); - }); - - jasmine.Ajax.requests.mostRecent().respondWith({ - status: 200, - contentType: 'json', - responseText: ratingOneMock - }); - }); - - it('Should post rating return an Observable', (done) => { - const ratingType: string = 'fiveStar'; - const nodeId: string = 'fake-node-id'; - - service.postRating(nodeId, ratingType, 3).subscribe((data) => { - expect(data.entry.myRating).toBe('3'); - done(); - }); - - jasmine.Ajax.requests.mostRecent().respondWith({ - status: 200, - contentType: 'json', - responseText: ratingThreeMock - }); - }); -}); diff --git a/lib/content-services/src/lib/social/services/rating.service.ts b/lib/content-services/src/lib/social/services/rating.service.ts deleted file mode 100644 index 172499ce36..0000000000 --- a/lib/content-services/src/lib/social/services/rating.service.ts +++ /dev/null @@ -1,73 +0,0 @@ -/*! - * @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 { AlfrescoApiService } from '@alfresco/adf-core'; -import { Injectable } from '@angular/core'; -import { RatingEntry, RatingBody, RatingsApi } from '@alfresco/js-api'; -import { from, Observable } from 'rxjs'; -import { RatingServiceInterface } from './rating.service.interface'; - -@Injectable({ - providedIn: 'root' -}) -export class RatingService implements RatingServiceInterface { - private _ratingsApi: RatingsApi; - get ratingsApi(): RatingsApi { - this._ratingsApi = this._ratingsApi ?? new RatingsApi(this.apiService.getInstance()); - return this._ratingsApi; - } - - constructor(private apiService: AlfrescoApiService) {} - - /** - * Gets the current user's rating for a node. - * - * @param nodeId Node to get the rating from - * @param ratingType Type of rating (can be "likes" or "fiveStar") - * @returns The rating value - */ - getRating(nodeId: string, ratingType: any): Observable { - return from(this.ratingsApi.getRating(nodeId, ratingType)); - } - - /** - * Adds the current user's rating for a node. - * - * @param nodeId Target node for the rating - * @param ratingType Type of rating (can be "likes" or "fiveStar") - * @param vote Rating value (boolean for "likes", numeric 0..5 for "fiveStar") - * @returns Details about the rating, including the new value - */ - postRating(nodeId: string, ratingType: string, vote: any): Observable { - const ratingBody: RatingBody = { - id: ratingType, - myRating: vote - }; - return from(this.ratingsApi.createRating(nodeId, ratingBody)); - } - - /** - * Removes the current user's rating for a node. - * - * @param nodeId Target node - * @param ratingType Type of rating to remove (can be "likes" or "fiveStar") - * @returns Null response indicating that the operation is complete - */ - deleteRating(nodeId: string, ratingType: any): Observable { - return from(this.ratingsApi.deleteRating(nodeId, ratingType)); - } -} diff --git a/lib/content-services/src/lib/social/social.module.ts b/lib/content-services/src/lib/social/social.module.ts deleted file mode 100644 index 732f087d08..0000000000 --- a/lib/content-services/src/lib/social/social.module.ts +++ /dev/null @@ -1,42 +0,0 @@ -/*! - * @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 { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; -import { MaterialModule } from '../material.module'; - -import { LikeComponent } from './like.component'; -import { RatingComponent } from './rating.component'; - -/** - * @deprecated This module uses Like and Rating components are not used in ACA/ADW/ACC and can be removed. - */ -@NgModule({ - imports: [ - CommonModule, - MaterialModule - ], - exports: [ - RatingComponent, - LikeComponent - ], - declarations: [ - RatingComponent, - LikeComponent - ] -}) -export class SocialModule {} diff --git a/lib/content-services/src/public-api.ts b/lib/content-services/src/public-api.ts index 72e32778cb..645ee26091 100644 --- a/lib/content-services/src/public-api.ts +++ b/lib/content-services/src/public-api.ts @@ -16,7 +16,6 @@ */ export * from './lib/directives/index'; -export * from './lib/social/index'; export * from './lib/tag/index'; export * from './lib/webscript/index'; export * from './lib/document-list/index';