diff --git a/src/app/ideation/components/edit-idea/edit-idea.component.html b/src/app/ideation/components/edit-idea/edit-idea.component.html index 82eb3df41..a6b8fbeaf 100644 --- a/src/app/ideation/components/edit-idea/edit-idea.component.html +++ b/src/app/ideation/components/edit-idea/edit-idea.component.html @@ -50,7 +50,7 @@
- + {{image.name}}
- + {{image.name}}
-
diff --git a/src/app/topic/components/topic-edit-disabled-dialog/topic-edit-disabled-dialog.component.spec.ts b/src/app/topic/components/topic-edit-disabled-dialog/topic-edit-disabled-dialog.component.spec.ts index b792e3971..622675267 100644 --- a/src/app/topic/components/topic-edit-disabled-dialog/topic-edit-disabled-dialog.component.spec.ts +++ b/src/app/topic/components/topic-edit-disabled-dialog/topic-edit-disabled-dialog.component.spec.ts @@ -1,6 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { TopicEditDisabledDialogComponent } from './topic-edit-disabled-dialog.component'; +import { TranslateModule, TranslatePipe } from '@ngx-translate/core'; describe('TopicEditDisabledDialogComponent', () => { let component: TopicEditDisabledDialogComponent; @@ -8,7 +9,8 @@ describe('TopicEditDisabledDialogComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [TopicEditDisabledDialogComponent] + declarations: [TopicEditDisabledDialogComponent], + imports: [TranslateModule.forRoot(), TranslatePipe] }); fixture = TestBed.createComponent(TopicEditDisabledDialogComponent); component = fixture.componentInstance; diff --git a/src/app/topic/components/topic-form/topic-form.component.ts b/src/app/topic/components/topic-form/topic-form.component.ts index f7e8624d2..6750e7d51 100644 --- a/src/app/topic/components/topic-form/topic-form.component.ts +++ b/src/app/topic/components/topic-form/topic-form.component.ts @@ -25,6 +25,8 @@ import { Attachment } from 'src/app/interfaces/attachment'; import { TopicAttachmentService } from '@services/topic-attachment.service'; import { GroupMemberTopicService } from '@services/group-member-topic.service'; import { TopicDiscussionService } from '@services/topic-discussion.service'; +import { TopicEditDisabledDialogComponent } from '../topic-edit-disabled-dialog/topic-edit-disabled-dialog.component'; +import { TopicSettingsLockedComponent } from '../topic-settings-locked/topic-settings-locked.component'; @Component({ selector: 'topic-form', @@ -80,11 +82,11 @@ export class TopicFormComponent { } else { const contentChilds = content.nativeElement.children[2]?.children; let h = 0; - for (let i = 0; i < contentChilds.length; i++) { - h += contentChilds[i].offsetHeight; + for (const child of contentChilds) { + h += child.offsetHeight; if (h >= 320) { this.readMoreButton.next(true); - i = contentChilds.length; + break; } } } @@ -122,7 +124,7 @@ export class TopicFormComponent { groups$: Observable = of([]); groupsList = []; loadMembers$ = new BehaviorSubject(undefined); - members$: Observable = of([]); + members$: Observable = of([]); loadInvite$ = new BehaviorSubject(undefined); invites$: Observable = of([]); topicGroups = []; @@ -231,7 +233,26 @@ export class TopicFormComponent { return fragment } ), tap((fragment) => { - if (fragment === 'settings' && !this.TopicService.canDelete(this.topic)) { + if (fragment === 'discussion' && !this.TopicService.canEditDescription(this.topic)) { + const infoDialog = dialog.open(TopicSettingsLockedComponent); + infoDialog.afterClosed().subscribe(() => { + if (this.TopicService.canDelete(this.topic)) { + this.selectTab('settings') + } else { + this.selectTab('preview') + } + }); + } + else if (fragment === 'info' && !this.TopicService.canEditDescription(this.topic)) { + const infoDialog = dialog.open(TopicEditDisabledDialogComponent); + infoDialog.afterClosed().subscribe(() => { + if (this.TopicService.canDelete(this.topic)) { + this.selectTab('settings') + } else { + this.selectTab('preview') + } + }); + } else if (fragment === 'settings' && !this.TopicService.canDelete(this.topic)) { const infoDialog = this.dialog.open(TopicSettingsDisabledDialogComponent); infoDialog.afterClosed().subscribe(() => { this.selectTab('info') @@ -314,11 +335,7 @@ export class TopicFormComponent { isNextDisabled(tabSelected: string | void) { - if (tabSelected === 'preview' && !this.TopicService.canDelete(this.topic)) { - return true; - } else if (!this.topic.title || !this.topic.description) { - return true; - } else if (tabSelected === 'discussion' && !this.discussion.question) { + if ((tabSelected === 'preview' && !this.TopicService.canDelete(this.topic)) || !this.topic.title || !this.topic.description || (tabSelected === 'discussion' && !this.discussion.question)) { return true; } @@ -492,7 +509,7 @@ export class TopicFormComponent { saveAsDraft() { if (this.topic.status === this.TopicService.STATUSES.draft) { - const updateTopic = Object.assign({}, this.topic); + const updateTopic = { ...this.topic }; if (!updateTopic.intro?.length) { updateTopic.intro = null; } @@ -545,9 +562,8 @@ export class TopicFormComponent { publish() { this.titleInput?.nativeElement?.parentNode.parentNode.classList.remove('error'); - const isDraft = (this.topic.status === this.TopicService.STATUSES.draft); this.topic.status = this.TopicService.STATUSES.inProgress; - const updateTopic = Object.assign({}, this.topic); + const updateTopic = { ...this.topic }; if (!updateTopic.intro?.length) { updateTopic.intro = null; } @@ -600,7 +616,7 @@ export class TopicFormComponent { } createDiscussion(updateTopicStatus?: boolean) { - const createDiscussion: any = Object.assign({ topicId: this.topic.id, discussionId: this.discussion.id }, this.discussion); + const createDiscussion: any = { topicId: this.topic.id, discussionId: this.discussion.id, ...this.discussion }; this.TopicDiscussionService.save(createDiscussion) .pipe(take(1)) .subscribe({ @@ -609,7 +625,7 @@ export class TopicFormComponent { this.discussion = discussion; if (updateTopicStatus) { const isDraft = (this.topic.status === this.TopicService.STATUSES.draft); - const updateTopic = Object.assign({}, this.topic); + const updateTopic = { ...this.topic }; updateTopic.status = this.TopicService.STATUSES.inProgress; this.TopicService.patch(updateTopic).pipe(take(1)).subscribe({ next: (res) => { @@ -643,7 +659,7 @@ export class TopicFormComponent { updateDiscussion(updateTopicStatus?: boolean) { - const updateDiscussion = Object.assign({ topicId: this.topic.id, discussionId: this.discussion.id }, this.discussion); + const updateDiscussion = { topicId: this.topic.id, discussionId: this.discussion.id , ...this.discussion}; return this.TopicDiscussionService.update(updateDiscussion).pipe(take(1)).subscribe({ next: () => { if (updateTopicStatus) { diff --git a/src/app/topic/components/topic-settings-locked/topic-settings-locked.component.html b/src/app/topic/components/topic-settings-locked/topic-settings-locked.component.html new file mode 100644 index 000000000..003e04393 --- /dev/null +++ b/src/app/topic/components/topic-settings-locked/topic-settings-locked.component.html @@ -0,0 +1,58 @@ +
+
+
+ +
+
+
+ +
+
+
+ + + + + + +
+
+ +
+
diff --git a/src/app/topic/components/topic-settings-locked/topic-settings-locked.component.scss b/src/app/topic/components/topic-settings-locked/topic-settings-locked.component.scss new file mode 100644 index 000000000..e0afe036c --- /dev/null +++ b/src/app/topic/components/topic-settings-locked/topic-settings-locked.component.scss @@ -0,0 +1,29 @@ +.dialog { + max-width: 560px; + + .header_with_icon { + gap: 16px; + padding-bottom: 24px; + } + + .dialog_content { + gap: 24px; + } + + .dialog_info { + background-color: var(--color-argument-info-light); + font-size: 14px; + font-style: normal; + font-weight: 400; + line-height: 20px; + padding: 16px; + gap: 16px; + + .bold { + font-size: 14px; + font-style: normal; + font-weight: 600; + line-height: 16px; + } + } +} diff --git a/src/app/topic/components/topic-settings-locked/topic-settings-locked.component.spec.ts b/src/app/topic/components/topic-settings-locked/topic-settings-locked.component.spec.ts new file mode 100644 index 000000000..daf2db474 --- /dev/null +++ b/src/app/topic/components/topic-settings-locked/topic-settings-locked.component.spec.ts @@ -0,0 +1,38 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { TopicSettingsLockedComponent } from './topic-settings-locked.component'; + +describe('TopicSettingsLockedComponent', () => { + let component: TopicSettingsLockedComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [TopicSettingsLockedComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(TopicSettingsLockedComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); + + it('should have the correct selector', () => { + const compiled = fixture.nativeElement; + expect(compiled.querySelector('app-topic-settings-locked')).toBeTruthy(); + }); + + it('should have the correct template URL', () => { + const metadata = Reflect.getMetadata('annotations', TopicSettingsLockedComponent)[0]; + expect(metadata.templateUrl).toBe('./topic-settings-locked.component.html'); + }); + + it('should have the correct style URL', () => { + const metadata = Reflect.getMetadata('annotations', TopicSettingsLockedComponent)[0]; + expect(metadata.styleUrls).toContain('./topic-settings-locked.component.scss'); + }); +}); diff --git a/src/app/topic/components/topic-settings-locked/topic-settings-locked.component.ts b/src/app/topic/components/topic-settings-locked/topic-settings-locked.component.ts new file mode 100644 index 000000000..ba55200b7 --- /dev/null +++ b/src/app/topic/components/topic-settings-locked/topic-settings-locked.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-topic-settings-locked', + templateUrl: './topic-settings-locked.component.html', + styleUrl: './topic-settings-locked.component.scss' +}) +export class TopicSettingsLockedComponent { + +} diff --git a/src/app/topic/topic.component.html b/src/app/topic/topic.component.html index a18eb4537..254d1607e 100644 --- a/src/app/topic/topic.component.html +++ b/src/app/topic/topic.component.html @@ -152,7 +152,7 @@ + *ngIf="(auth.loggedIn$ | async) && topic.ideationId && TopicService.canEdit(topic) && ([TopicService.STATUSES.draft, TopicService.STATUSES.ideation, TopicService.STATUSES.followUp].indexOf(topic.status) > -1)">
+ *ngIf="(auth.loggedIn$ | async) && topic.voteId && (TopicService.canDelete(topic) || (TopicService.canEdit(topic) && ([TopicService.STATUSES.draft, TopicService.STATUSES.voting, TopicService.STATUSES.followUp].indexOf(topic.status) > -1)))">
+ *ngIf="(auth.loggedIn$ | async) && topic.ideationId && TopicService.canEdit(topic) && ([TopicService.STATUSES.draft, TopicService.STATUSES.ideation, TopicService.STATUSES.followUp].indexOf(topic.status) > -1)">
+ *ngIf="(auth.loggedIn$ | async) && topic.voteId && TopicService.canEdit(topic) && ([TopicService.STATUSES.draft, TopicService.STATUSES.voting, TopicService.STATUSES.followUp].indexOf(topic.status) > -1)">
+ *ngIf="(auth.loggedIn$ | async) && topic.ideationId && TopicService.canEdit(topic) && ([TopicService.STATUSES.draft, TopicService.STATUSES.ideation, TopicService.STATUSES.followUp].indexOf(topic.status) > -1)">
+ *ngIf="(auth.loggedIn$ | async) && topic.voteId && TopicService.canEdit(topic) && ([TopicService.STATUSES.draft, TopicService.STATUSES.voting, TopicService.STATUSES.followUp].indexOf(topic.status) > -1)">