Skip to content

Commit

Permalink
General: Disable readonly input elements (#8114)
Browse files Browse the repository at this point in the history
  • Loading branch information
milljoniaer committed Mar 2, 2024
1 parent 9bf300a commit 6e44346
Show file tree
Hide file tree
Showing 24 changed files with 27 additions and 76 deletions.
Expand Up @@ -9,10 +9,6 @@ <h2 id="jhi-lecture-heading" jhiTranslate="artemisApp.lti.addOrEditLtiPlatform">
</div>
</div>
<div>
<div class="form-group" [hidden]="!platform?.id">
<label for="id" jhiTranslate="global.field.id">ID</label>
<input type="text" class="form-control" id="id" name="id" formControlName="id" readonly />
</div>
<div class="form-group mt-2" [hidden]="!platform?.registrationId">
<label class="form-control-label" jhiTranslate="artemisApp.lti.registrationId" for="field_registrationId">Registration Id</label>
<jhi-help-icon text="artemisApp.lti.edit.registrationIdTooltip" />
Expand Down
Expand Up @@ -3,10 +3,6 @@
<form name="editForm" role="form" novalidate (ngSubmit)="save()" #editForm="ngForm">
<h2 jhiTranslate="artemisApp.organizationManagement.addOrEditLabel">Add or edit a Organization</h2>
<div>
<div class="form-group" [hidden]="!organization.id">
<label for="id" jhiTranslate="global.field.id">ID</label>
<input id="id" type="text" class="form-control" name="id" [(ngModel)]="organization.id" readonly />
</div>
<div class="form-group">
<label for="name" class="form-control-label" jhiTranslate="artemisApp.organizationManagement.name">Name</label>
<input id="name" type="text" class="form-control" name="name" #nameInput="ngModel" [(ngModel)]="organization.name" required minlength="1" maxlength="100" />
Expand Down
Expand Up @@ -3,10 +3,6 @@
<form name="editForm" role="form" (ngSubmit)="save()" #editForm="ngForm" [formGroup]="form">
<h2 id="myNotificationLabel" jhiTranslate="artemisApp.systemNotification.createOrEditLabel">Create or edit a system notification</h2>
<div>
<div class="form-group" [hidden]="!notification.id">
<label for="id" jhiTranslate="global.field.id">ID</label>
<input id="id" type="text" class="form-control" name="id" formControlName="id" readonly />
</div>
<div class="form-group">
<label for="title" class="form-control-label" jhiTranslate="artemisApp.systemNotification.title">Title</label>
<input id="title" type="text" class="form-control" name="title" formControlName="title" />
Expand Down
Expand Up @@ -3,10 +3,6 @@
<form name="editForm" role="form" novalidate (ngSubmit)="save()" [formGroup]="editForm">
<h2 id="myUserLabel" jhiTranslate="artemisApp.userManagement.home.createOrEditLabel">Create or edit a User</h2>
<div>
<div class="form-group" [hidden]="!user.id">
<label for="id" jhiTranslate="global.field.id">ID</label>
<input id="id" type="text" class="form-control" name="id" formControlName="idInput" [(ngModel)]="user.id" readonly />
</div>
<div class="form-group">
<label for="login" class="form-control-label" jhiTranslate="artemisApp.userManagement.login">Login</label>
<input
Expand Down
Expand Up @@ -45,8 +45,8 @@
step="0.5"
[(ngModel)]="feedback.credits"
(ngModelChange)="emitChanges()"
[readOnly]="feedback.gradingInstruction || readOnly"
[disabled]="readOnly"
[disabled]="!!feedback.gradingInstruction || readOnly"
[readOnly]="!!feedback.gradingInstruction || readOnly"
[required]="!feedback.gradingInstruction"
/>
</div>
Expand Down
Expand Up @@ -17,10 +17,6 @@ <h4 id="jhi-course-heading-edit" jhiTranslate="artemisApp.course.home.editLabel"
</div>
<hr />
<div>
<div class="form-group" [hidden]="!course.id">
<label for="id" jhiTranslate="global.field.id">ID</label>
<input type="text" class="form-control" id="id" name="id" formControlName="id" readonly />
</div>
<div class="row">
<div class="col">
<div class="form-group">
Expand Down
11 changes: 7 additions & 4 deletions src/main/webapp/app/course/manage/course-update.component.ts
Expand Up @@ -160,10 +160,13 @@ export class CourseUpdateComponent implements OnInit {
{
id: new FormControl(this.course.id),
title: new FormControl(this.course.title, [Validators.required]),
shortName: new FormControl(this.course.shortName, {
validators: [Validators.required, Validators.minLength(3), regexValidator(SHORT_NAME_PATTERN)],
updateOn: 'blur',
}),
shortName: new FormControl(
{ value: this.course.shortName, disabled: !!this.course.id },
{
validators: [Validators.required, Validators.minLength(3), regexValidator(SHORT_NAME_PATTERN)],
updateOn: 'blur',
},
),
// note: we still reference them here so that they are used in the update method when the course is retrieved from the course form
customizeGroupNames: new FormControl(this.customizeGroupNames),
studentGroupName: new FormControl(this.course.studentGroupName),
Expand Down
14 changes: 1 addition & 13 deletions src/main/webapp/app/exam/manage/exams/exam-update.component.html
Expand Up @@ -18,18 +18,6 @@ <h4>{{ 'artemisApp.examManagement.editExam' | artemisTranslate }}</h4>
<div>
<hr />
<h5 class="pb-1" jhiTranslate="artemisApp.examManagement.sections.configuration">Exam Configuration</h5>
@if (exam.course) {
<div class="form-group">
<label class="form-control-label" for="course" jhiTranslate="artemisApp.examManagement.courseTitle">Course Title</label>
<input id="course" name="course" readonly type="text" class="form-control" [value]="exam.course.title" />
</div>
}
@if (exam.id) {
<div class="form-group">
<label class="form-check-label" for="id" jhiTranslate="artemisApp.examManagement.examId">Exam ID</label>
<input class="form-control" type="text" id="id" name="id" [value]="exam.id" readonly />
</div>
}
<label class="form-check-label" jhiTranslate="artemisApp.examManagement.examTitle">Exam Title</label>
<jhi-title-channel-name
[(title)]="exam.title"
Expand Down Expand Up @@ -123,7 +111,7 @@ <h5 class="pb-1" jhiTranslate="artemisApp.examManagement.sections.conduction">Ex
<label class="form-check-label" for="workingTimeInMinutes" jhiTranslate="artemisApp.examManagement.workingTime">Working Time</label>
<jhi-help-icon [text]="'artemisApp.examManagement' + (exam.testExam ? '.testExam' : '') + '.workingTimeTooltip'" />
@if (!exam.testExam) {
<input readonly type="text" class="form-control" [value]="workingTimeInMinutes" />
<input readonly disabled type="text" class="form-control" [value]="workingTimeInMinutes" />
}
@if (exam.testExam) {
<input
Expand Down
Expand Up @@ -28,8 +28,8 @@
class="text-editor-textarea"
[maxLength]="maxCharacterCount"
[(ngModel)]="answer"
[readonly]="readonly || !studentSubmission"
[disabled]="!studentSubmission"
[readOnly]="readonly || !studentSubmission"
[disabled]="readonly || !studentSubmission"
(keydown.tab)="onTextEditorTab(textEditor, $event)"
(input)="onTextEditorInput($event)"
></textarea>
Expand Down
Expand Up @@ -12,10 +12,6 @@ <h2 id="jhi-file-upload-exercise-heading-import" jhiTranslate="artemisApp.fileUp
<jhi-form-status-bar [formStatusSections]="formStatusSections" />
<h3 jhiTranslate="artemisApp.exercise.sections.general" id="artemisApp.exercise.sections.general">General Information</h3>
<div>
<div class="form-group" [hidden]="!fileUploadExercise.id || isImport">
<label for="id" jhiTranslate="global.field.id">ID</label>
<input type="text" class="form-control" id="id" name="id" [(ngModel)]="fileUploadExercise.id" readonly />
</div>
<jhi-exercise-title-channel-name
[exercise]="fileUploadExercise"
[course]="fileUploadExercise.course"
Expand Down
Expand Up @@ -12,10 +12,6 @@ <h2 id="jhi-modeling-exercise-heading-import" jhiTranslate="artemisApp.modelingE
<jhi-form-status-bar [formStatusSections]="formSectionStatus" />
<div>
<h3 jhiTranslate="artemisApp.exercise.sections.general" id="artemisApp.exercise.sections.general">General Information</h3>
<div class="form-group" [hidden]="!modelingExercise.id">
<label for="id" jhiTranslate="global.field.id">ID</label>
<input type="text" class="form-control" id="id" name="id" [(ngModel)]="modelingExercise.id" readonly />
</div>
<jhi-exercise-title-channel-name [exercise]="modelingExercise" [course]="modelingExercise.course" [isExamMode]="isExamMode" [isImport]="isImport" />
@if (!isExamMode) {
<div class="form-group position-relative">
Expand Down
Expand Up @@ -8,4 +8,5 @@
(keydown.tab)="onTextEditorTab(textEditor, $event)"
(ngModelChange)="onExplanationInput($event)"
[readOnly]="readOnly"
[disabled]="readOnly"
></textarea>
Expand Up @@ -6,10 +6,6 @@
General Information
</h3>
<p jhiTranslate="artemisApp.programmingExercise.wizardMode.detailedSteps.generalInfoStepMessage">Add some general information about the new exercise</p>
<div class="form-group" [hidden]="isImport || !programmingExercise.id">
<label for="id" jhiTranslate="global.field.id">ID</label>
<input type="text" class="form-control" id="id" name="id" [(ngModel)]="programmingExercise.id" readonly />
</div>
<div class="form-group">
<div>
<label jhiTranslate="artemisApp.exercise.title">Title</label>
Expand Down Expand Up @@ -39,7 +35,8 @@
minlength="3"
[pattern]="programmingExerciseCreationConfig.shortNamePattern"
[(ngModel)]="programmingExercise.shortName"
[readonly]="!programmingExerciseCreationConfig.isImportFromExistingExercise && programmingExercise.id"
[readOnly]="!programmingExerciseCreationConfig.isImportFromExistingExercise && !!programmingExercise.id"
[disabled]="!programmingExerciseCreationConfig.isImportFromExistingExercise && !!programmingExercise.id"
#shortName="ngModel"
/>
@for (error of shortName.errors! | keyvalue | removekeys: ['required']; track error) {
Expand Down
Expand Up @@ -58,7 +58,7 @@ export class ProgrammingExerciseInformationComponent implements AfterViewInit, O
const areAuxiliaryRepositoriesValid = this.areAuxiliaryRepositoriesValid();
this.formValid = Boolean(
this.exerciseTitleChannelComponent.titleChannelNameComponent?.formValid &&
this.shortNameField.valid &&
!this.shortNameField.invalid &&
isCheckoutSolutionRepositoryValid &&
isRecreateBuildPlansValid &&
isUpdateTemplateFilesValid &&
Expand Down
Expand Up @@ -30,10 +30,6 @@ <h4>
</div>
</div>
}
<div class="form-group" [hidden]="isImport || !quizExercise.id">
<label for="id" jhiTranslate="global.field.id">ID</label>
<input type="text" class="form-control" id="id" name="id" [(ngModel)]="quizExercise.id" readonly />
</div>
<div class="edit-quiz">
<form name="editForm" role="form" novalidate>
<jhi-exercise-title-channel-name
Expand Down
Expand Up @@ -5,10 +5,6 @@ <h2 id="jhi-exercise-hint-heading" [jhiTranslate]="'artemisApp.exerciseHint.home
Create or edit a Exercise Hint
</h2>
<div>
<div class="form-group" [hidden]="!exerciseHint?.id">
<label for="id" jhiTranslate="global.field.id">ID</label>
<input type="text" class="form-control" id="id" name="id" readonly [(ngModel)]="exerciseHint.id" />
</div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="artemisApp.exerciseHint.title" for="field_title">Title</label>
<input type="text" required minlength="3" class="form-control" name="title" id="field_title" [(ngModel)]="exerciseHint.title" />
Expand Down
Expand Up @@ -45,7 +45,8 @@ <h4 class="modal-title">
[pattern]="shortNamePattern"
[(ngModel)]="pendingTeam.shortName"
(ngModelChange)="onTeamShortNameChanged($event)"
[readonly]="shortNameReadOnly"
[disabled]="shortNameReadOnly"
[readOnly]="shortNameReadOnly"
#shortName="ngModel"
/>
@for (e of shortName.errors! | keyvalue | removekeys: ['required']; track e) {
Expand Down
Expand Up @@ -83,6 +83,7 @@
(keydown.escape)="escKeyup()"
(focus)="inFocus()"
[readOnly]="readOnly"
[disabled]="readOnly"
(ngModelChange)="didChange()"
></textarea>
</div>
Expand All @@ -98,6 +99,7 @@
(focus)="inFocus()"
(ngModelChange)="didChange()"
[readOnly]="feedback.gradingInstruction || readOnly"
[disabled]="!!feedback.gradingInstruction || readOnly"
/>
</div>
</div>
Expand Down
Expand Up @@ -12,10 +12,6 @@ <h2 id="jhi-text-exercise-heading-import" jhiTranslate="artemisApp.textExercise.
<jhi-form-status-bar [formStatusSections]="formSectionStatus" />
<div>
<h3 jhiTranslate="artemisApp.exercise.sections.general" id="artemisApp.exercise.sections.general">General Information</h3>
<div class="form-group" [hidden]="isImport || !textExercise.id">
<label for="id" jhiTranslate="global.field.id">ID</label>
<input type="text" class="form-control" id="id" name="id" [(ngModel)]="textExercise.id" readonly />
</div>
<jhi-exercise-title-channel-name [exercise]="textExercise" [course]="textExercise.course" [minTitleLength]="3" [isImport]="isImport" [isExamMode]="isExamMode" />
@if (!isExamMode) {
<div class="form-group position-relative">
Expand Down
Expand Up @@ -46,8 +46,8 @@
class="text-editor-textarea"
[maxLength]="maxCharacterCount"
[(ngModel)]="answer"
[readonly]="!isActive || !submission || !isOwnerOfParticipation"
[disabled]="!isActive || !submission"
[readOnly]="!isActive || !submission || !isOwnerOfParticipation"
[disabled]="!isActive || !submission || !isOwnerOfParticipation"
(keydown.tab)="onTextEditorTab(textEditor, $event)"
(input)="onTextEditorInput($event)"
></textarea>
Expand Down
Expand Up @@ -111,7 +111,7 @@
</div>
<div class="form-group">
<label for="version">{{ 'artemisApp.attachmentUnit.createAttachmentUnit.version' | artemisTranslate }}</label>
<input id="version" class="form-control" type="text" readonly formControlName="version" />
<input id="version" class="form-control disabled" type="text" readonly formControlName="version" />
</div>
<div class="row">
<div class="col-12">
Expand Down
Expand Up @@ -88,7 +88,7 @@ export class AttachmentUnitFormComponent implements OnInit, OnChanges {
name: [undefined as string | undefined, [Validators.required, Validators.maxLength(255)]],
description: [undefined as string | undefined, [Validators.maxLength(1000)]],
releaseDate: [undefined as dayjs.Dayjs | undefined],
version: [1],
version: [{ value: 1, disabled: true, readOnly: true }],
updateNotificationText: [undefined as string | undefined, [Validators.maxLength(1000)]],
competencies: [undefined as Competency[] | undefined],
});
Expand Down
4 changes: 0 additions & 4 deletions src/main/webapp/app/lecture/lecture-update.component.html
Expand Up @@ -27,10 +27,6 @@ <h2 id="jhi-lecture-heading" jhiTranslate="artemisApp.lecture.home.createOrEditL
</div>
</div>
<div>
<div class="form-group" [hidden]="!lecture.id">
<label for="id" jhiTranslate="global.field.id">ID</label>
<input type="text" class="form-control" id="id" name="id" [(ngModel)]="lecture.id" readonly />
</div>
<jhi-lecture-title-channel-name [lecture]="lecture" />
<div class="form-group" id="field_description">
<label class="form-control-label" jhiTranslate="artemisApp.lecture.description" for="field_description">Description</label>
Expand Down
Expand Up @@ -8,6 +8,7 @@
<textarea
class="form-control"
readonly
disabled
placeholder="dummyPlaceholder"
id="name"
value="{{ channelOrGroupChat.name ?? ('artemisApp.dialogs.conversationDetail.infoTab.noName' | artemisTranslate) }}"
Expand All @@ -32,6 +33,7 @@
<textarea
class="form-control large"
readonly
disabled
placeholder="dummyPlaceholder"
id="topic"
value="{{ channel.topic ?? ('artemisApp.dialogs.conversationDetail.infoTab.noTopic' | artemisTranslate) }}"
Expand All @@ -53,6 +55,7 @@
<textarea
class="form-control large"
readonly
disabled
placeholder="dummyPlaceholder"
id="description"
value="{{ channel.description ?? ('artemisApp.dialogs.conversationDetail.infoTab.noDescription' | artemisTranslate) }}"
Expand Down

0 comments on commit 6e44346

Please sign in to comment.