Skip to content

Commit f3c3b8f

Browse files
Simone-RamundiAndrea Barbasso
authored andcommitted
Merged in task/dspace-cris-2023_02_x/DSC-1872 (pull request DSpace#2155)
Task/dspace cris 2023 02 x/DSC-1872 Approved-by: Andrea Barbasso
2 parents 3f05ceb + 089abe8 commit f3c3b8f

27 files changed

Lines changed: 322 additions & 58 deletions

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@
145145
"ng2-nouislider": "^2.0.0",
146146
"ngx-infinite-scroll": "^15.0.0",
147147
"ngx-pagination": "6.0.3",
148-
"ngx-ui-switch": "^14.0.3",
149148
"nouislider": "^15.7.1",
150149
"pem": "1.14.7",
151150
"prop-types": "^15.8.1",

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ <h2 id="header">{{'admin.batch-import.page.header' | translate}}</h2>
2020
</small>
2121
</div>
2222

23-
<ui-switch color="#ebebeb"
24-
[checkedLabel]="'admin.metadata-import.page.toggle.upload' | translate"
25-
[uncheckedLabel]="'admin.metadata-import.page.toggle.url' | translate"
26-
[checked]="isUpload"
27-
(change)="toggleUpload()" ></ui-switch>
23+
<ds-switch
24+
[options]="switchOptions"
25+
[selectedValue]="isUpload ? 'upload' : 'url'"
26+
(selectedValueChange)="toggleUpload()">
27+
</ds-switch>
2828
<small class="form-text text-muted">
2929
{{'admin.batch-import.page.toggle.help' | translate}}
3030
</small>

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
1717
import { take } from 'rxjs/operators';
1818
import { DSpaceObject } from '../../core/shared/dspace-object.model';
1919
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
20+
import { SwitchColor, SwitchOption } from '../../shared/switch/switch.component';
2021

2122
@Component({
2223
selector: 'ds-batch-import-page',
@@ -48,6 +49,14 @@ export class BatchImportPageComponent {
4849
*/
4950
fileURL: string;
5051

52+
/**
53+
* The custom options for the 'ds-switch' component
54+
*/
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+
];
59+
5160
public constructor(private location: Location,
5261
protected translate: TranslateService,
5362
protected notificationsService: NotificationsService,
@@ -154,4 +163,5 @@ export class BatchImportPageComponent {
154163
toggleUpload() {
155164
this.isUpload = !this.isUpload;
156165
}
166+
157167
}

src/app/admin/admin.module.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { ExpandableAdminSidebarSectionComponent } from './admin-sidebar/expandab
1212
import { AdminEditUserAgreementComponent } from './admin-edit-user-agreement/admin-edit-user-agreement.component';
1313
import { EditCmsMetadataComponent } from './edit-cms-metadata/edit-cms-metadata.component';
1414
import { BatchImportPageComponent } from './admin-import-batch-page/batch-import-page.component';
15-
import { UiSwitchModule } from 'ngx-ui-switch';
1615
import { UploadModule } from '../shared/upload/upload.module';
1716

1817
const ENTRY_COMPONENTS = [
@@ -30,7 +29,6 @@ const ENTRY_COMPONENTS = [
3029
AdminSearchModule.withEntryComponents(),
3130
AdminWorkflowModuleModule.withEntryComponents(),
3231
SharedModule,
33-
UiSwitchModule,
3432
UploadModule,
3533
],
3634
declarations: [

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
ThemedExternalLoginReviewAccountInfoPageComponent
99
} from './themed-external-login-review-account-info-page.component';
1010
import { ReviewAccountInfoComponent } from './review-account-info/review-account-info.component';
11-
import { UiSwitchModule } from 'ngx-ui-switch';
1211
import { SharedModule } from '../shared/shared.module';
1312
import { ExternalLoginModule } from '../external-log-in/external-login.module';
1413

@@ -23,7 +22,6 @@ import { ExternalLoginModule } from '../external-log-in/external-login.module';
2322
CommonModule,
2423
ExternalLoginReviewAccountInfoRoutingModule,
2524
SharedModule,
26-
UiSwitchModule,
2725
ExternalLoginModule
2826
]
2927
})

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@ <h2> {{'external-login-validation.review-account-info.header' | translate}}</h2>
4040
</span>
4141
</td>
4242
<td>
43-
<ui-switch
43+
<ds-switch
4444
*ngIf="(data.receivedValue !== data.currentValue) && data.currentValue"
45-
[checkedLabel]="'on-label' | translate"
46-
[uncheckedLabel]="'off-label' | translate"
47-
[checked]="data.overrideValue"
48-
(change)="onOverrideChange($event, data.identifier)"
49-
></ui-switch>
45+
[options]="switchOptions"
46+
[selectedValue]="data.overrideValue"
47+
(selectedValueChange)="onOverrideChange($event, data.identifier)">
48+
</ds-switch>
5049
</td>
5150
</tr>
5251
</tbody>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ describe('ReviewAccountInfoComponent', () => {
190190
const firstDataRow = dataRows[1];
191191
const firstDataLabel: HTMLElement = firstDataRow.querySelector('th');
192192
const firstDataReceivedValue: HTMLElement = firstDataRow.querySelectorAll('td')[0];
193-
const firstDataOverrideSwitch: HTMLElement = firstDataRow.querySelector('ui-switch');
193+
const firstDataOverrideSwitch: HTMLElement = firstDataRow.querySelector('ds-switch');
194194
expect(firstDataLabel.textContent.trim()).toBe('Lastname');
195195
expect(firstDataReceivedValue.textContent.trim()).toBe('Doe');
196196
expect(firstDataOverrideSwitch).toBeNull();

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { HardRedirectService } from '../../core/services/hard-redirect.service';
1515
import { AuthRegistrationType } from '../../core/auth/models/auth.registration-type';
1616
import { ExternalLoginService } from '../../external-log-in/services/external-login.service';
1717
import { NativeWindowRef, NativeWindowService } from '../../core/services/window.service';
18+
import { SwitchColor, SwitchOption } from '../../shared/switch/switch.component';
1819

1920
export interface ReviewAccountInfoData {
2021
label: string;
@@ -53,6 +54,14 @@ export class ReviewAccountInfoComponent implements OnInit, OnDestroy {
5354
*/
5455
subs: Subscription[] = [];
5556

57+
/**
58+
* The custom options for the 'ds-switch' component
59+
*/
60+
switchOptions: SwitchOption[] = [
61+
{ value: true, labelColor: SwitchColor.Success, backgroundColor: SwitchColor.Success ,label: 'on-label' },
62+
{ value: false, label: 'off-label' },
63+
];
64+
5665
constructor(
5766
@Inject(NativeWindowService) protected _window: NativeWindowRef,
5867
private ePersonService: EPersonDataService,

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
<p>{{'researcher.profile.associated' | translate}}</p>
44
<p class="align-items-center researcher-profile-switch" >
55
<span class="mr-3">{{'researcher.profile.status' | translate}}</span>
6-
<ui-switch [checkedLabel]="'researcher.profile.public.visibility' | translate"
7-
[uncheckedLabel]="'researcher.profile.private.visibility' | translate"
8-
[checked]="researcherProfile.visible"
9-
(change)="toggleProfileVisibility(researcherProfile)" ></ui-switch>
6+
<ds-switch
7+
[options]="switchOptions"
8+
[selectedValue]="researcherProfile.visible ? 'public' : 'private'"
9+
(selectedValueChange)="toggleProfileVisibility(researcherProfile)">
10+
</ds-switch>
1011
</p>
1112
</div>
1213
<div *ngIf="!researcherProfile">

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { isNotEmpty } from '../../shared/empty.util';
1919
import { followLink } from '../../shared/utils/follow-link-config.model';
2020
import { ConfirmationModalComponent } from '../../shared/confirmation-modal/confirmation-modal.component';
2121
import { NoContent } from '../../core/shared/NoContent.model';
22+
import { SwitchColor, SwitchOption } from '../../shared/switch/switch.component';
2223

2324
@Component({
2425
selector: 'ds-profile-page-researcher-form',
@@ -56,6 +57,14 @@ export class ProfilePageResearcherFormComponent implements OnInit {
5657
*/
5758
researcherProfileItemId: string;
5859

60+
/**
61+
* The custom options for the 'ds-switch' component
62+
*/
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+
];
67+
5968
constructor(protected researcherProfileService: ResearcherProfileDataService,
6069
protected profileClaimService: ProfileClaimService,
6170
protected translationService: TranslateService,

0 commit comments

Comments
 (0)