Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

using new default pattern form form input and validation styling, adjusted text as required

Jonas Jabari3ccdeb510e2e
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 0045dd43e6e..ebd4c3edd08 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -760,6 +760,11 @@ en:
overlaps: 'overlap.'
outside: 'is outside of the grid.'
end_before_start: 'end value needs to be larger than the start value.'
+ ical_token_query_assignment:
+ attributes:
+ name:
+ blank: "is mandatory. Please select a name."
+ not_unique: "is already in use. Please select another name."
notifications:
at_least_one_channel: 'At least one channel for sending notifications needs to be specified.'
attributes:
diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml
index d374f974185..8e5dc970ff7 100644
--- a/config/locales/js-en.yml
+++ b/config/locales/js-en.yml
@@ -357,17 +357,16 @@ en:
</ul>
ical_sharing_modal:
- title: "Share iCalendar"
+ title: "Subscribe to iCalendar"
inital_setup_error_message: "An error occured while fetching data"
inital_setup_error_message: "An error occured while fetching data"
description: "You can use the iCalendar URL to import or subscribe to this calendar in an external client and view up-to-date work package information from there."
warning: "Please don't share this URL with external users. Anyone with this link will be able to view work package details without an account or password."
- token_name_label: "Token name"
- token_name_placeholder: "Type a name for this token, e.g. 'My calendar application'"
- token_name_description_text: "The token name will be used to identify the token in the list of <a href=\"my/access_token\", target=\"_blank\">iCalendar tokens</a>. It can only be used once per calendar."
+ token_name_label: "Name"
+ token_name_placeholder: "Type iCalendar name"
+ token_name_description_text: "This name will be used to distinguish it form other tokens in the <a href=\"my/access_token\", target=\"_blank\">access tokens list</a>. It can only be used once per calendar."
copy_url_label: "Copy URL"
ical_generation_error_text: "An error occured while generating the iCal URL"
- token_name_already_in_use_error_text: "This name is already in use for this query. Please select another name."
copy_url_success_text: "URL copied to clipboard"
copy_url_error_text: "couldn't be copied to clipboard"
@@ -1173,7 +1172,7 @@ en:
save_as: "Save as"
export: "Export"
visibility_settings: "Visibility settings"
- share_calendar: "Share iCalendar"
+ share_calendar: "Subscribe to iCalendar"
page_settings: "Rename view"
delete: "Delete"
filter: "Filter"
diff --git a/frontend/src/app/features/work-packages/openproject-work-packages.module.ts b/frontend/src/app/features/work-packages/openproject-work-packages.module.ts
index 25dca70679e..9e93dfbcf0e 100644
--- a/frontend/src/app/features/work-packages/openproject-work-packages.module.ts
+++ b/frontend/src/app/features/work-packages/openproject-work-packages.module.ts
@@ -30,6 +30,7 @@ import {
Injector,
NgModule,
} from '@angular/core';
+import { ReactiveFormsModule } from '@angular/forms';
import { OpSharedModule } from 'core-app/shared/shared.module';
import { OpenprojectFieldsModule } from 'core-app/shared/components/fields/openproject-fields.module';
import { OpenprojectModalModule } from 'core-app/shared/components/modal/modal.module';
@@ -210,6 +211,7 @@ import { OpBaselineLoadingComponent } from 'core-app/features/work-packages/comp
EditFieldControlsModule,
OpenprojectTabsModule,
OpenprojectStoragesModule,
+ ReactiveFormsModule
],
providers: [
// Notification service
diff --git a/frontend/src/app/shared/components/modals/get-ical-url-modal/query-get-ical-url.modal.html b/frontend/src/app/shared/components/modals/get-ical-url-modal/query-get-ical-url.modal.html
index 54507891a94..d69d365e00f 100644
--- a/frontend/src/app/shared/components/modals/get-ical-url-modal/query-get-ical-url.modal.html
+++ b/frontend/src/app/shared/components/modals/get-ical-url-modal/query-get-ical-url.modal.html
@@ -1,7 +1,7 @@
-<form
- name="getIcalUrlForm"
- (submit)="generateAndCopyUrl($event)"
+<form
class="spot-modal loading-indicator--location op-query-get-ical-url"
+ [formGroup]="tokenNameForm"
+ (submit)="generateAndCopyUrl($event)"
>
<div class="spot-modal--header">{{text.label_ical_sharing}}</div>
@@ -20,35 +20,28 @@
{{text.description_ical_sharing}}
</p>
- <!-- <label class="form--label -bold" for="name" [textContent]="text.token_name"></label> -->
-
- <h5>{{text.token_name}}</h5>
-
- <p [innerHtml]="text.token_name_description_text"></p>
-
- <div class="form--field -required ">
- <div class="form--field-container">
- <div class="form--text-field-container">
- <input
- class="form--text-field"
- type="text"
- name="name"
- id="name"
- #tokenNameField
- [(ngModel)]="tokenName"
- [placeholder]="text.token_name_placeholder"
- required
- />
- </div>
+ <spot-form-field [label]="text.token_name" [required]="true" showValidationErrorOn="change">
+
+ <spot-text-field
+ formControlName="name"
+ slot="input"
+ [placeholder]="text.token_name_placeholder"
+ ></spot-text-field>
+
+ <div
+ slot="errors"
+ class="spot-form-field--error"
+ *ngIf="nameControl?.errors?.rails"
+ >
+ {{nameControl?.errors?.rails}}
</div>
- </div>
- <div *ngIf="hasErrors">
- <p class="error-text">
- {{text.token_name_already_in_use_error_text}}
- </p>
- </div>
-
+ <span
+ slot="description"
+ [innerHtml]="text.token_name_description_text"
+ ></span>
+
+ </spot-form-field>
</div>
<div class="spot-action-bar">
@@ -60,7 +53,7 @@
<button type="submit" class="button button_no-margin -highlight -with-icon icon-copy spot-action-bar--action"
(click)="generateAndCopyUrl($event)"
[textContent]="text.button_copy"
- [disabled]="isBusy || !tokenName">
+ [disabled]="isBusy">
</button>
</div>
</div>
diff --git a/frontend/src/app/shared/components/modals/get-ical-url-modal/query-get-ical-url.modal.sass b/frontend/src/app/shared/components/modals/get-ical-url-modal/query-get-ical-url.modal.sass
index 298ca3ad5f7..0eb61622ae6 100644
--- a/frontend/src/app/shared/components/modals/get-ical-url-modal/query-get-ical-url.modal.sass
+++ b/frontend/src/app/shared/components/modals/get-ical-url-modal/query-get-ical-url.modal.sass
@@ -1,12 +1,4 @@
.op-query-get-ical-url
.ical-url
word-break: break-word
- .form--text-field
- // TODO: find default error styling approach
- &.-error
- border: 2px solid red
- background: #fedada
- .error-text
- color: red
- font-size: 0.8rem
diff --git a/frontend/src/app/shared/components/modals/get-ical-url-modal/query-get-ical-url.modal.ts b/frontend/src/app/shared/components/modals/get-ical-url-modal/query-get-ical-url.modal.ts
index 971f8ff7308..8b11efa3f34 100644
--- a/frontend/src/app/shared/components/modals/get-ical-url-modal/query-get-ical-url.modal.ts
+++ b/frontend/src/app/shared/components/modals/get-ical-url-modal/query-get-ical-url.modal.ts
@@ -36,12 +36,17 @@ import { OpModalLocalsMap } from 'core-app/shared/components/modal/modal.types';
import {
ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, Inject, OnInit, ViewChild
} from '@angular/core';
+import {
+ UntypedFormGroup,
+ UntypedFormControl,
+ Validators,
+ AbstractControl,
+} from '@angular/forms';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { IsolatedQuerySpace } from 'core-app/features/work-packages/directives/query-space/isolated-query-space';
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
import { QueryResource } from 'core-app/features/hal/resources/query-resource';
-import { timeout } from 'rxjs/operators';
@Component({
templateUrl: './query-get-ical-url.modal.html',
@@ -55,11 +60,6 @@ export class QueryGetIcalUrlModalComponent extends OpModalComponent implements O
public isBusy = false;
- public hasErrors = false;
-
-
- @ViewChild('tokenNameField', { static: true }) tokenNameField:ElementRef;
-
public text = {
label_ical_sharing: this.I18n.t('js.ical_sharing_modal.title'),
description_ical_sharing: this.I18n.t('js.ical_sharing_modal.description'),
@@ -74,6 +74,15 @@ export class QueryGetIcalUrlModalComponent extends OpModalComponent implements O
close_popup: this.I18n.t('js.close_popup_title'),
};
+ public tokenNameForm = new UntypedFormGroup({
+ // eslint-disable-next-line @typescript-eslint/unbound-method
+ name: new UntypedFormControl(null, [Validators.required]),
+ });
+
+ get nameControl():AbstractControl|null {
+ return this.tokenNameForm.get('name');
+ }
+
constructor(
readonly elementRef:ElementRef,
@Inject(OpModalLocalsToken) public locals:OpModalLocalsMap,
@@ -106,10 +115,6 @@ export class QueryGetIcalUrlModalComponent extends OpModalComponent implements O
}
}
- public onOpen():void {
- this.tokenNameField.nativeElement.focus();
- }
-
public copyUrlAndCloseModal(url:string):void {
void navigator.clipboard.writeText(url)
.then(() => {
@@ -131,12 +136,14 @@ export class QueryGetIcalUrlModalComponent extends OpModalComponent implements O
let icalUrl = "";
+ let tokenName = this.tokenNameForm.value.name;
+
this.isBusy = true;
const promise = this
.apiV3Service
.queries
- .getIcalUrl(this.query, this.tokenName);
+ .getIcalUrl(this.query, tokenName);
void promise
.then((response:HalResource) => {
@@ -144,13 +151,9 @@ export class QueryGetIcalUrlModalComponent extends OpModalComponent implements O
this.copyUrlAndCloseModal(icalUrl);
})
.catch((error:any) => {
- this.halNotification.handleRawError(error)
-
- this.hasErrors = true
-
- const el = this.tokenNameField.nativeElement;
- el.classList.add('-error'); //TODO: find default error styling approach
-
+ this.nameControl?.markAsDirty();
+ this.nameControl?.setErrors({ rails: error.message });
+
this.cdRef.detectChanges();
})
.then(() => this.isBusy = false); // Same as .finally()
diff --git a/modules/calendar/app/models/ical_token_query_assignment.rb b/modules/calendar/app/models/ical_token_query_assignment.rb
index db69f3678a4..9afb05b3dbc 100644
--- a/modules/calendar/app/models/ical_token_query_assignment.rb
+++ b/modules/calendar/app/models/ical_token_query_assignment.rb
@@ -65,7 +65,7 @@ class ICalTokenQueryAssignment < ApplicationRecord
.exists?
if name_already_taken_for_query_and_user
- errors.add(:name, "has already been taken for this query and user")
+ errors.add(:name, :not_unique)
end
end
end