Skip to content

Commit f1e1f01

Browse files
Francesco MautoAndrea Barbasso
authored andcommitted
Merged in task/dspace-cris-2025_02_x/DSC-2236 (pull request DSpace#5008)
[DSC-2236] edit: updated switch component logic to 2 options only Approved-by: Andrea Barbasso
2 parents 0adf619 + e197bcf commit f1e1f01

16 files changed

Lines changed: 173 additions & 100 deletions

bitbucket-pipelines.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
options:
2-
runs-on: self.hosted
3-
41
definitions:
52
caches:
63
cypress-dsc-2025-02-x: ~/.cache/Cypress

src/app/admin/admin-import-batch-page/batch-import-page.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ <h1 id="header">{{'admin.batch-import.page.header' | translate}}</h1>
2323
</div>
2424

2525
<ds-switch
26-
[options]="switchOptions"
26+
[onOption]="switchOnOption"
27+
[offOption]="switchOffOption"
2728
[selectedValue]="isUpload ? 'upload' : 'url'"
2829
(selectedValueChange)="toggleUpload()">
2930
</ds-switch>

src/app/admin/admin-import-batch-page/batch-import-page.component.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,14 @@ export class BatchImportPageComponent {
8080
fileURL: string;
8181

8282
/**
83-
* The custom options for the 'ds-switch' component
83+
* The "on" option for the 'ds-switch' component (upload)
8484
*/
85-
switchOptions: SwitchOption[] = [
86-
{ value: 'upload', icon: 'fa fa-upload', label: 'admin.metadata-import.page.toggle.upload', iconColor: SwitchColor.Primary },
87-
{ value: 'url', icon: 'fa fa-link', label: 'admin.metadata-import.page.toggle.url', iconColor: SwitchColor.Primary },
88-
];
85+
switchOnOption: SwitchOption = { value: 'upload', icon: 'fa fa-upload', label: 'admin.metadata-import.page.toggle.upload', iconColor: SwitchColor.Primary };
86+
87+
/**
88+
* The "off" option for the 'ds-switch' component (url)
89+
*/
90+
switchOffOption: SwitchOption = { value: 'url', icon: 'fa fa-link', label: 'admin.metadata-import.page.toggle.url', iconColor: SwitchColor.Primary };
8991

9092
public constructor(private location: Location,
9193
protected translate: TranslateService,

src/app/external-login-review-account-info-page/review-account-info/review-account-info.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ <h2> {{'external-login-validation.review-account-info.header' | translate}}</h2>
4343
<td>
4444
@if ((data.receivedValue !== data.currentValue) && data.currentValue) {
4545
<ds-switch
46-
[options]="switchOptions"
46+
[onOption]="switchOnOption"
47+
[offOption]="switchOffOption"
4748
[selectedValue]="data.overrideValue"
4849
(selectedValueChange)="onOverrideChange($event, data.identifier)">
4950
</ds-switch>

src/app/external-login-review-account-info-page/review-account-info/review-account-info.component.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,14 @@ export class ReviewAccountInfoComponent implements OnInit, OnDestroy {
103103
subs: Subscription[] = [];
104104

105105
/**
106-
* The custom options for the 'ds-switch' component
106+
* The "on" option for the 'ds-switch' component
107107
*/
108-
switchOptions: SwitchOption[] = [
109-
{ value: true, labelColor: SwitchColor.Success, backgroundColor: SwitchColor.Success ,label: 'on-label' },
110-
{ value: false, label: 'off-label' },
111-
];
108+
switchOnOption: SwitchOption = { value: true, labelColor: SwitchColor.Success, backgroundColor: SwitchColor.Success, label: 'on-label' };
109+
110+
/**
111+
* The "off" option for the 'ds-switch' component
112+
*/
113+
switchOffOption: SwitchOption = { value: false, label: 'off-label' };
112114

113115
constructor(
114116
@Inject(NativeWindowService) protected _window: NativeWindowRef,

src/app/info/accessibility-settings/accessibility-settings.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ <h2>{{ 'info.accessibility-settings.title' | translate }}</h2>
99

1010
<div class="col-sm-4">
1111
<ds-switch
12-
[options]="switchOptions"
12+
[onOption]="switchOnOption"
13+
[offOption]="switchOffOption"
1314
[(selectedValue)]="formValues.notificationTimeOutEnabled">
1415
</ds-switch>
1516
</div>

src/app/info/accessibility-settings/accessibility-settings.component.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,15 @@ export class AccessibilitySettingsComponent implements OnInit, OnDestroy {
6262
cookieIsAccepted: BehaviorSubject<boolean> = new BehaviorSubject(false);
6363

6464
/**
65-
* The custom options for the 'ds-switch' component
65+
* The "on" option for the 'ds-switch' component
6666
*/
67-
switchOptions: SwitchOption[] = [
68-
{ value: true, labelColor: SwitchColor.Success, backgroundColor: SwitchColor.Success ,
69-
label: 'info.accessibility-settings.notificationTimeOutEnabled.label.enabled' },
70-
{ value: false, label: 'info.accessibility-settings.notificationTimeOutEnabled.label.disabled' },
71-
];
67+
switchOnOption: SwitchOption = { value: true, labelColor: SwitchColor.Success, backgroundColor: SwitchColor.Success,
68+
label: 'info.accessibility-settings.notificationTimeOutEnabled.label.enabled' };
69+
70+
/**
71+
* The "off" option for the 'ds-switch' component
72+
*/
73+
switchOffOption: SwitchOption = { value: false, label: 'info.accessibility-settings.notificationTimeOutEnabled.label.disabled' };
7274

7375
private subscriptions: Subscription[] = [];
7476

src/app/profile-page/profile-page-researcher-form/profile-page-researcher-form.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
<p class="align-items-center researcher-profile-switch" >
66
<span class="me-3">{{'researcher.profile.status' | translate}}</span>
77
<ds-switch
8-
[options]="switchOptions"
8+
[onOption]="switchOnOption"
9+
[offOption]="switchOffOption"
910
[selectedValue]="researcherProfile.visible ? 'public' : 'private'"
1011
(selectedValueChange)="toggleProfileVisibility(researcherProfile)">
1112
</ds-switch>

src/app/profile-page/profile-page-researcher-form/profile-page-researcher-form.component.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,14 @@ export class ProfilePageResearcherFormComponent implements OnInit {
8787
researcherProfileItemId: string;
8888

8989
/**
90-
* The custom options for the 'ds-switch' component
90+
* The "on" option for the 'ds-switch' component (public)
9191
*/
92-
switchOptions: SwitchOption[] = [
93-
{ value: 'public', icon: 'fa fa-globe', labelColor: SwitchColor.Success, label: 'researcher.profile.public.visibility', iconColor: SwitchColor.Success },
94-
{ value: 'private', icon: 'fa fa-lock', labelColor: SwitchColor.Danger, label: 'researcher.profile.private.visibility', iconColor: SwitchColor.Danger },
95-
];
92+
switchOnOption: SwitchOption = { value: 'public', icon: 'fa fa-globe', labelColor: SwitchColor.Success, label: 'researcher.profile.public.visibility', iconColor: SwitchColor.Success };
93+
94+
/**
95+
* The "off" option for the 'ds-switch' component (private)
96+
*/
97+
switchOffOption: SwitchOption = { value: 'private', icon: 'fa fa-lock', labelColor: SwitchColor.Danger, label: 'researcher.profile.private.visibility', iconColor: SwitchColor.Danger };
9698

9799
constructor(protected researcherProfileService: ResearcherProfileDataService,
98100
protected profileClaimService: ProfileClaimService,

src/app/shared/access-control-form-container/access-control-form-container.component.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ <h2 class="h3 mb-0 me-4">
1919
</h2>
2020
<ds-switch
2121
[ariaLabel]="(state.bitstream.toggleStatus ? 'access-control-item-toggle.disable' : 'access-control-item-toggle.enable') | translate"
22-
[options]="switchOptions"
22+
[onOption]="switchOnOption"
23+
[offOption]="switchOffOption"
2324
[(selectedValue)] = "state.item.toggleStatus"
2425
(selectedValueChange) = "handleStatusChange('item', $event)">
2526
</ds-switch>
@@ -72,7 +73,8 @@ <h2 class="h3 mb-0 me-4">
7273
</h2>
7374
<ds-switch
7475
[ariaLabel]="(state.bitstream.toggleStatus ? 'access-control-bitstream-toggle.disable' : 'access-control-bitstream-toggle.enable') | translate"
75-
[options]="switchOptions"
76+
[onOption]="switchOnOption"
77+
[offOption]="switchOffOption"
7678
[(selectedValue)] = "state.bitstream.toggleStatus"
7779
(selectedValueChange) = "handleStatusChange('bitstream', $event)">
7880
</ds-switch>

0 commit comments

Comments
 (0)