Skip to content

Commit f82016a

Browse files
Francesco MautoAndrea Barbasso
authored andcommitted
Merged in task/dspace-cris-2024_02_x/DSC-2236 (pull request DSpace#5009)
[DSC-2236] edit: updated switch component logic to 2 options only Approved-by: Andrea Barbasso
2 parents a479062 + 60662db commit f82016a

16 files changed

Lines changed: 169 additions & 101 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-2024-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
@@ -21,7 +21,8 @@ <h1 id="header">{{'admin.batch-import.page.header' | translate}}</h1>
2121
</div>
2222

2323
<ds-switch
24-
[options]="switchOptions"
24+
[onOption]="switchOnOption"
25+
[offOption]="switchOffOption"
2526
[selectedValue]="isUpload ? 'upload' : 'url'"
2627
(selectedValueChange)="toggleUpload()">
2728
</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
@@ -85,12 +85,14 @@ export class BatchImportPageComponent {
8585
fileURL: string;
8686

8787
/**
88-
* The custom options for the 'ds-switch' component
88+
* The "on" option for the 'ds-switch' component (upload)
8989
*/
90-
switchOptions: SwitchOption[] = [
91-
{ value: 'upload', icon: 'fa fa-upload', label: 'admin.metadata-import.page.toggle.upload', iconColor: SwitchColor.Primary },
92-
{ value: 'url', icon: 'fa fa-link', label: 'admin.metadata-import.page.toggle.url', iconColor: SwitchColor.Primary },
93-
];
90+
switchOnOption: SwitchOption = { value: 'upload', icon: 'fa fa-upload', label: 'admin.metadata-import.page.toggle.upload', iconColor: SwitchColor.Primary };
91+
92+
/**
93+
* The "off" option for the 'ds-switch' component (url)
94+
*/
95+
switchOffOption: SwitchOption = { value: 'url', icon: 'fa fa-link', label: 'admin.metadata-import.page.toggle.url', iconColor: SwitchColor.Primary };
9496

9597
public constructor(private location: Location,
9698
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
@@ -42,7 +42,8 @@ <h2> {{'external-login-validation.review-account-info.header' | translate}}</h2>
4242
<td>
4343
<ds-switch
4444
*ngIf="(data.receivedValue !== data.currentValue) && data.currentValue"
45-
[options]="switchOptions"
45+
[onOption]="switchOnOption"
46+
[offOption]="switchOffOption"
4647
[selectedValue]="data.overrideValue"
4748
(selectedValueChange)="onOverrideChange($event, data.identifier)">
4849
</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
@@ -100,12 +100,14 @@ export class ReviewAccountInfoComponent implements OnInit, OnDestroy {
100100
subs: Subscription[] = [];
101101

102102
/**
103-
* The custom options for the 'ds-switch' component
103+
* The "on" option for the 'ds-switch' component
104104
*/
105-
switchOptions: SwitchOption[] = [
106-
{ value: true, labelColor: SwitchColor.Success, backgroundColor: SwitchColor.Success ,label: 'on-label' },
107-
{ value: false, label: 'off-label' },
108-
];
105+
switchOnOption: SwitchOption = { value: true, labelColor: SwitchColor.Success, backgroundColor: SwitchColor.Success, label: 'on-label' };
106+
107+
/**
108+
* The "off" option for the 'ds-switch' component
109+
*/
110+
switchOffOption: SwitchOption = { value: false, label: 'off-label' };
109111

110112
constructor(
111113
@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
@@ -67,13 +67,15 @@ export class AccessibilitySettingsComponent implements OnInit, OnDestroy {
6767
cookieIsAccepted: BehaviorSubject<boolean> = new BehaviorSubject(false);
6868

6969
/**
70-
* The custom options for the 'ds-switch' component
70+
* The "on" option for the 'ds-switch' component
7171
*/
72-
switchOptions: SwitchOption[] = [
73-
{ value: true, labelColor: SwitchColor.Success, backgroundColor: SwitchColor.Success ,
74-
label: 'info.accessibility-settings.notificationTimeOutEnabled.label.enabled' },
75-
{ value: false, label: 'info.accessibility-settings.notificationTimeOutEnabled.label.disabled' },
76-
];
72+
switchOnOption: SwitchOption = { value: true, labelColor: SwitchColor.Success, backgroundColor: SwitchColor.Success,
73+
label: 'info.accessibility-settings.notificationTimeOutEnabled.label.enabled' };
74+
75+
/**
76+
* The "off" option for the 'ds-switch' component
77+
*/
78+
switchOffOption: SwitchOption = { value: false, label: 'info.accessibility-settings.notificationTimeOutEnabled.label.disabled' };
7779

7880
private subscriptions: Subscription[] = [];
7981

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
@@ -4,7 +4,8 @@
44
<p class="align-items-center researcher-profile-switch" >
55
<span class="mr-3">{{'researcher.profile.status' | translate}}</span>
66
<ds-switch
7-
[options]="switchOptions"
7+
[onOption]="switchOnOption"
8+
[offOption]="switchOffOption"
89
[selectedValue]="researcherProfile.visible ? 'public' : 'private'"
910
(selectedValueChange)="toggleProfileVisibility(researcherProfile)">
1011
</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
@@ -92,12 +92,14 @@ export class ProfilePageResearcherFormComponent implements OnInit {
9292
researcherProfileItemId: string;
9393

9494
/**
95-
* The custom options for the 'ds-switch' component
95+
* The "on" option for the 'ds-switch' component (public)
9696
*/
97-
switchOptions: SwitchOption[] = [
98-
{ value: 'public', icon: 'fa fa-globe', labelColor: SwitchColor.Success, label: 'researcher.profile.public.visibility', iconColor: SwitchColor.Success },
99-
{ value: 'private', icon: 'fa fa-lock', labelColor: SwitchColor.Danger, label: 'researcher.profile.private.visibility', iconColor: SwitchColor.Danger },
100-
];
97+
switchOnOption: SwitchOption = { value: 'public', icon: 'fa fa-globe', labelColor: SwitchColor.Success, label: 'researcher.profile.public.visibility', iconColor: SwitchColor.Success };
98+
99+
/**
100+
* The "off" option for the 'ds-switch' component (private)
101+
*/
102+
switchOffOption: SwitchOption = { value: 'private', icon: 'fa fa-lock', labelColor: SwitchColor.Danger, label: 'researcher.profile.private.visibility', iconColor: SwitchColor.Danger };
101103

102104
constructor(protected researcherProfileService: ResearcherProfileDataService,
103105
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
@@ -18,7 +18,8 @@ <h2 class="h3 mb-0 mr-4">
1818
</h2>
1919
<ds-switch
2020
[ariaLabel]="(state.bitstream.toggleStatus ? 'access-control-item-toggle.disable' : 'access-control-item-toggle.enable') | translate"
21-
[options]="switchOptions"
21+
[onOption]="switchOnOption"
22+
[offOption]="switchOffOption"
2223
[(selectedValue)] = "state.item.toggleStatus"
2324
(selectedValueChange) = "handleStatusChange('item', $event)">
2425
</ds-switch>
@@ -73,7 +74,8 @@ <h2 class="h3 mb-0 mr-4">
7374
</h2>
7475
<ds-switch
7576
[ariaLabel]="(state.bitstream.toggleStatus ? 'access-control-bitstream-toggle.disable' : 'access-control-bitstream-toggle.enable') | translate"
76-
[options]="switchOptions"
77+
[onOption]="switchOnOption"
78+
[offOption]="switchOffOption"
7779
[(selectedValue)] = "state.bitstream.toggleStatus"
7880
(selectedValueChange) = "handleStatusChange('bitstream', $event)">
7981
</ds-switch>

0 commit comments

Comments
 (0)