Skip to content

Commit 01a67c2

Browse files
committed
add disabling for form, checkboxes, file-upload
1 parent 0ae01b0 commit 01a67c2

11 files changed

Lines changed: 27 additions & 2 deletions

projects/social_platform/src/app/office/courses/lesson/lesson.component.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<app-write-task
4646
[data]="task"
4747
[type]="task.answerType === 'text_and_files' ? 'text-file' : 'text'"
48+
[disabled]="isViewingCompleted()"
4849
(update)="onAnswerChange($event)"
4950
></app-write-task>
5051
}
@@ -55,6 +56,7 @@
5556
[data]="task"
5657
[success]="success()"
5758
[error]="hasError()"
59+
[disabled]="isViewingCompleted()"
5860
(update)="onAnswerChange($event)"
5961
></app-exclude-task>
6062
}
@@ -65,6 +67,7 @@
6567
[data]="task"
6668
[success]="success()"
6769
[error]="hasError()"
70+
[disabled]="isViewingCompleted()"
6871
(update)="onAnswerChange([$event.answerId])"
6972
></app-radio-select-task>
7073
}
@@ -75,6 +78,7 @@
7578
[data]="task"
7679
[success]="success()"
7780
[error]="hasError()"
81+
[disabled]="isViewingCompleted()"
7882
(update)="onAnswerChange($event)"
7983
></app-file-task>
8084
}

projects/social_platform/src/app/office/courses/lesson/shared/exclude-task/exclude-task.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
class="exclude__item"
4949
[class.exclude__item--success]="success && result().includes(op.id)"
5050
[class.exclude__item--error]="error"
51+
[class.exclude__item--disabled]="disabled"
5152
(click)="onSelect(op.id)"
5253
>
5354
<app-checkbox size="10" [checked]="result().includes(op.id)"></app-checkbox>

projects/social_platform/src/app/office/courses/lesson/shared/exclude-task/exclude-task.component.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@
7171
}
7272
}
7373

74+
&--disabled {
75+
pointer-events: none;
76+
opacity: 0.6;
77+
}
78+
7479
label {
7580
cursor: pointer;
7681
}

projects/social_platform/src/app/office/courses/lesson/shared/exclude-task/exclude-task.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export class ExcludeTaskComponent implements OnInit {
5757
@Output() update = new EventEmitter<number[]>(); // Событие обновления выбранных ответов
5858

5959
@Input() success = false; // Флаг успешного выполнения
60+
@Input() disabled = false;
6061

6162
@Input()
6263
set error(value: boolean) {
@@ -104,6 +105,7 @@ export class ExcludeTaskComponent implements OnInit {
104105
* @param id - ID варианта ответа
105106
*/
106107
onSelect(id: number) {
108+
if (this.disabled) return;
107109
if (this.result().includes(id)) {
108110
// Если вариант уже выбран, убираем его из списка
109111
this.result.set(this.result().filter(i => i !== id));

projects/social_platform/src/app/office/courses/lesson/shared/file-task/file-task.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
<p class="file-task__label text-body-12">ответ</p>
6666
<p class="file-task__title text-body-12-bold">{{ data.answerTitle | truncate: 80 }}</p>
6767

68+
@if (!disabled) {
6869
<div class="file-task__files">
6970
<app-upload-file [resetAfterUpload]="true" (uploaded)="onFileUploaded($event)">
7071
<div emptyPlaceholder class="file-task__upload">
@@ -85,5 +86,6 @@
8586
></app-file-item>
8687
}
8788
</div>
89+
}
8890
</div>
8991
</div>

projects/social_platform/src/app/office/courses/lesson/shared/file-task/file-task.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export class FileTaskComponent implements OnInit {
4848
@Input({ required: true }) data!: Task;
4949
@Input() success = false;
5050
@Input() hint = "";
51+
@Input() disabled = false;
5152

5253
@Input()
5354
set error(value: boolean) {

projects/social_platform/src/app/office/courses/lesson/shared/radio-select-task/radio-select-task.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@
5555
class="radio__item"
5656
[class.radio__item--success]="success && result().answerId === op.id"
5757
[class.radio__item--error]="error && result().answerId === op.id"
58+
[class.radio__item--disabled]="disabled"
5859
(click)="onSelect(op.id)"
5960
>
60-
<input type="radio" [id]="op.id" name="radio-group" />
61+
<input type="radio" [id]="op.id" name="radio-group" [disabled]="disabled" />
6162
<label class="text-body-12" [for]="op.id">
6263
{{ op.text }}
6364
</label>

projects/social_platform/src/app/office/courses/lesson/shared/radio-select-task/radio-select-task.component.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@
106106
background-color: var(--red);
107107
}
108108
}
109+
110+
&--disabled {
111+
pointer-events: none;
112+
opacity: 0.6;
113+
}
109114
}
110115

111116
&__body,

projects/social_platform/src/app/office/courses/lesson/shared/radio-select-task/radio-select-task.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export class RadioSelectTaskComponent implements OnInit {
3434
@Input({ required: true }) data!: Task;
3535
@Input() success = false;
3636
@Input() hint = "";
37+
@Input() disabled = false;
3738

3839
@Input()
3940
set error(value: boolean) {
@@ -80,6 +81,7 @@ export class RadioSelectTaskComponent implements OnInit {
8081
}
8182

8283
onSelect(id: number) {
84+
if (this.disabled) return;
8385
this.result.set({ answerId: id });
8486
this.update.emit({ answerId: id });
8587
}

projects/social_platform/src/app/office/courses/lesson/shared/write-task/write-task.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
attr.maxlength="{{ maxLength }}"
5959
(input)="onKeyUp($event)"
6060
placeholder="ваш ответ"
61+
[disabled]="disabled"
6162
></textarea>
6263
<div class="write-task__counter">
6364
<p class="text-body-10">
@@ -66,7 +67,7 @@
6667
</div>
6768
</div>
6869

69-
@if (type === 'text-file') {
70+
@if (type === 'text-file' && !disabled) {
7071
<div class="write-task__files">
7172
<app-upload-file [resetAfterUpload]="true" (uploaded)="onFileUploaded($event)">
7273
<div emptyPlaceholder class="write-task__upload">

0 commit comments

Comments
 (0)