-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-Authored-by: Bertrand Zuchuat <[email protected]>
- Loading branch information
1 parent
b4f8eeb
commit ff37c62
Showing
19 changed files
with
1,042 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
projects/admin/src/app/api/organisation-api.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* RERO ILS UI | ||
* Copyright (C) 2021-2023 RERO | ||
* Copyright (C) 2021-2023 UCLouvain | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { RecordService } from '@rero/ng-core'; | ||
import { of } from 'rxjs'; | ||
import { OrganisationApiService } from './organisation-api.service'; | ||
import { HttpClientTestingModule } from '@angular/common/http/testing'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
|
||
describe('OrganisationApiService', () => { | ||
let service: OrganisationApiService; | ||
|
||
const response = { | ||
metadata: { | ||
name: 'Organisation name' | ||
} | ||
} | ||
const recordServiceSpy = jasmine.createSpyObj('RecordService', ['getRecord']); | ||
recordServiceSpy.getRecord.and.returnValue(of(response)); | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
HttpClientTestingModule, | ||
TranslateModule.forRoot() | ||
], | ||
providers: [ | ||
{ provide: RecordService, useValue: recordServiceSpy } | ||
] | ||
}); | ||
service = TestBed.inject(OrganisationApiService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
|
||
it('should return the organization\'s data', () => { | ||
service.getByPid('1').subscribe((data: any) => { | ||
expect(data.name).toEqual(response.metadata.name); | ||
}); | ||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* RERO ILS UI | ||
* Copyright (C) 2021-2023 RERO | ||
* Copyright (C) 2021-2023 UCLouvain | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
import { Injectable } from '@angular/core'; | ||
import { RecordService } from '@rero/ng-core'; | ||
import { Observable } from 'rxjs'; | ||
import { map } from 'rxjs/operators'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class OrganisationApiService { | ||
|
||
constructor(private recordService: RecordService) { } | ||
|
||
getByPid(pid: string): Observable<any> { | ||
return this.recordService.getRecord('organisations', pid) | ||
.pipe(map(record => record.metadata)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
projects/admin/src/app/record/editor/type/field-custom.type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* RERO ILS UI | ||
* Copyright (C) 2019-2023 RERO | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { FieldType } from '@ngx-formly/core'; | ||
|
||
@Component({ | ||
selector: 'admin-field-custom-input', | ||
template: ` | ||
<div class="form-group m-0 d-flex align-items-start"> | ||
<!-- label --> | ||
<label [attr.for]="id" class="mr-2 col-form-label" *ngIf="to.label && to.hideLabel !== true" [tooltip]="to.description"> | ||
{{ to.label }}<ng-container *ngIf="to.required && to.hideRequiredMarker !== true"> *</ng-container> | ||
</label> | ||
<!-- field --> | ||
<div class="flex-grow-1"> | ||
<ng-container [ngSwitch]="field.type"> | ||
<formly-field *ngSwitchCase="'input'" [field]="field"></formly-field> | ||
<formly-field *ngSwitchCase="'select'" [field]="field"></formly-field> | ||
</ng-container> | ||
</div> | ||
</div> | ||
`, | ||
}) | ||
export class FieldCustomInputTypeComponent extends FieldType implements OnInit { | ||
|
||
/** OnInit hook */ | ||
ngOnInit(): void { | ||
// We delete the class, as it is already set to the top level by the config. | ||
if (Object.keys(this.field).includes('className')) { | ||
delete this.field.className; | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
projects/admin/src/app/record/editor/type/repeat-section.type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* RERO ILS UI | ||
* Copyright (C) 2019-2023 RERO | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
import { Component } from '@angular/core'; | ||
import { FieldArrayType } from '@ngx-formly/core'; | ||
|
||
@Component({ | ||
selector: 'admin-repeat-section', | ||
template: ` | ||
<div *ngFor="let field of field.fieldGroup; let i = index;" class="row"> | ||
<div class="col-11"> | ||
<formly-field [field]="field"></formly-field> | ||
</div> | ||
<div class="col-1 my-0 d-flex align-items-center"> | ||
<button | ||
*ngIf="field.parent.fieldGroup.length > to.minItems" | ||
class="btn" | ||
type="button" | ||
(click)="remove(i)" | ||
><i class="fa fa-trash text-danger" aria-hidden="true"></i></button> | ||
<button | ||
*ngIf="field.parent.templateOptions.maxItems > field.parent.fieldGroup.length && field.parent.fieldGroup.length -1 === i" | ||
class="btn" | ||
type="button" | ||
(click)="add()" | ||
><i class="fa fa-plus-circle text-primary" aria-hidden="true"></i></button> | ||
</div> | ||
</div> | ||
`, | ||
}) | ||
export class RepeatTypeComponent extends FieldArrayType { } |
Oops, something went wrong.