Skip to content

Commit 7d51841

Browse files
Francesco MautoAndrea Barbasso
authored andcommitted
Merged in task/dspace-cris-2023_02_x/DSC-2236 (pull request DSpace#5010)
[DSC-2236] edit: updated switch component logic to 2 options only Approved-by: Andrea Barbasso
2 parents 9417fb3 + abf5cc9 commit 7d51841

16 files changed

Lines changed: 177 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
node-dsc-2023-02-x: ./node_modules

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+
[checkedOption]="switchOnOption"
25+
[uncheckedOption]="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
@@ -50,12 +50,14 @@ export class BatchImportPageComponent {
5050
fileURL: string;
5151

5252
/**
53-
* The custom options for the 'ds-switch' component
53+
* The "on" option for the 'ds-switch' component (upload)
5454
*/
55-
switchOptions: SwitchOption[] = [
56-
{ value: 'upload', icon: 'fa fa-upload', label: 'admin.metadata-import.page.toggle.upload', iconColor: SwitchColor.Primary },
57-
{ value: 'url', icon: 'fa fa-link', label: 'admin.metadata-import.page.toggle.url', iconColor: SwitchColor.Primary },
58-
];
55+
switchOnOption: SwitchOption = { value: 'upload', icon: 'fa fa-upload', label: 'admin.metadata-import.page.toggle.upload', iconColor: SwitchColor.Primary };
56+
57+
/**
58+
* The "off" option for the 'ds-switch' component (url)
59+
*/
60+
switchOffOption: SwitchOption = { value: 'url', icon: 'fa fa-link', label: 'admin.metadata-import.page.toggle.url', iconColor: SwitchColor.Primary };
5961

6062
public constructor(private location: Location,
6163
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+
[checkedOption]="switchOnOption"
46+
[uncheckedOption]="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
@@ -55,12 +55,14 @@ export class ReviewAccountInfoComponent implements OnInit, OnDestroy {
5555
subs: Subscription[] = [];
5656

5757
/**
58-
* The custom options for the 'ds-switch' component
58+
* The "on" option for the 'ds-switch' component
5959
*/
60-
switchOptions: SwitchOption[] = [
61-
{ value: true, labelColor: SwitchColor.Success, backgroundColor: SwitchColor.Success ,label: 'on-label' },
62-
{ value: false, label: 'off-label' },
63-
];
60+
switchOnOption: SwitchOption = { value: true, labelColor: SwitchColor.Success, backgroundColor: SwitchColor.Success, label: 'on-label' };
61+
62+
/**
63+
* The "off" option for the 'ds-switch' component
64+
*/
65+
switchOffOption: SwitchOption = { value: false, label: 'off-label' };
6466

6567
constructor(
6668
@Inject(NativeWindowService) protected _window: NativeWindowRef,

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ <h2>{{ 'info.accessibility-settings.title' | translate }}</h2>
88
</label>
99

1010
<div class="col-sm-4">
11-
<ds-switch [id]="'disableNotificationTimeOutInput'"
12-
[options]="notificationTimeOutSwitchOptions"
13-
[selectedValue]="formValues.notificationTimeOutEnabled"
14-
(selectedValueChange)="formValues.notificationTimeOutEnabled = $event">
11+
<ds-switch
12+
[id]="'disableNotificationTimeOutInput'"
13+
[checkedOption]="switchOnOption"
14+
[uncheckedOption]="switchOffOption"
15+
[(selectedValue)]="formValues.notificationTimeOutEnabled"
16+
(selectedValueChange)="formValues.notificationTimeOutEnabled = $event">
1517
</ds-switch>
1618
</div>
1719

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,20 @@ export class AccessibilitySettingsComponent implements OnInit, OnDestroy {
2626

2727
protected formValues: AccessibilitySettingsFormValues;
2828

29-
notificationTimeOutSwitchOptions: SwitchOption[] = [
30-
{ value: true, label: 'info.accessibility-settings.disableNotificationTimeOut.on', labelColor: SwitchColor.Success, backgroundColor: SwitchColor.Success },
31-
{ value: false, label: 'info.accessibility-settings.disableNotificationTimeOut.off' },
32-
];
33-
3429
isAuthenticated: BehaviorSubject<boolean> = new BehaviorSubject(false);
3530
cookieIsAccepted: BehaviorSubject<boolean> = new BehaviorSubject(false);
3631

32+
/**
33+
* The "on" option for the 'ds-switch' component
34+
*/
35+
switchOnOption: SwitchOption = { value: true, labelColor: SwitchColor.Success, backgroundColor: SwitchColor.Success,
36+
label: 'info.accessibility-settings.notificationTimeOutEnabled.label.enabled' };
37+
38+
/**
39+
* The "off" option for the 'ds-switch' component
40+
*/
41+
switchOffOption: SwitchOption = { value: false, label: 'info.accessibility-settings.notificationTimeOutEnabled.label.disabled' };
42+
3743
private subscriptions: Subscription[] = [];
3844

3945
constructor(

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+
[checkedOption]="switchOnOption"
8+
[uncheckedOption]="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
@@ -58,12 +58,14 @@ export class ProfilePageResearcherFormComponent implements OnInit {
5858
researcherProfileItemId: string;
5959

6060
/**
61-
* The custom options for the 'ds-switch' component
61+
* The "on" option for the 'ds-switch' component (public)
6262
*/
63-
switchOptions: SwitchOption[] = [
64-
{ value: 'public', icon: 'fa fa-globe', labelColor: SwitchColor.Success, label: 'researcher.profile.public.visibility', iconColor: SwitchColor.Success },
65-
{ value: 'private', icon: 'fa fa-lock', labelColor: SwitchColor.Danger, label: 'researcher.profile.private.visibility', iconColor: SwitchColor.Danger },
66-
];
63+
switchOnOption: SwitchOption = { value: 'public', icon: 'fa fa-globe', labelColor: SwitchColor.Success, label: 'researcher.profile.public.visibility', iconColor: SwitchColor.Success };
64+
65+
/**
66+
* The "off" option for the 'ds-switch' component (private)
67+
*/
68+
switchOffOption: SwitchOption = { value: 'private', icon: 'fa fa-lock', labelColor: SwitchColor.Danger, label: 'researcher.profile.private.visibility', iconColor: SwitchColor.Danger };
6769

6870
constructor(protected researcherProfileService: ResearcherProfileDataService,
6971
protected profileClaimService: ProfileClaimService,

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ <h2 class="h3 mb-0 mr-4">
1717
{{ 'access-control-item-header-toggle' | translate }}
1818
</h2>
1919
<ds-switch
20-
[options]="switchOptions"
20+
[ariaLabel]="(state.bitstream.toggleStatus ? 'access-control-item-toggle.disable' : 'access-control-item-toggle.enable') | translate"
21+
[checkedOption]="switchOnOption"
22+
[uncheckedOption]="switchOffOption"
2123
[(selectedValue)] = "state.item.toggleStatus"
2224
(selectedValueChange) = "handleStatusChange('item', $event)">
2325
</ds-switch>
@@ -71,7 +73,9 @@ <h2 class="h3 mb-0 mr-4">
7173
{{'access-control-bitstream-header-toggle' | translate}}
7274
</h2>
7375
<ds-switch
74-
[options]="switchOptions"
76+
[ariaLabel]="(state.bitstream.toggleStatus ? 'access-control-bitstream-toggle.disable' : 'access-control-bitstream-toggle.enable') | translate"
77+
[checkedOption]="switchOnOption"
78+
[uncheckedOption]="switchOffOption"
7579
[(selectedValue)] = "state.bitstream.toggleStatus"
7680
(selectedValueChange) = "handleStatusChange('bitstream', $event)">
7781
</ds-switch>

0 commit comments

Comments
 (0)