Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

form options (for ebook): item type and location for online status #532

Merged
merged 1 commit into from
Oct 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions data/item_types.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"description": "Standard checkout.",
"organisation": {
"$ref": "https://ils.rero.ch/api/organisations/1"
}
},
"type": "standard"
},
{
"pid": "2",
Expand All @@ -15,7 +16,8 @@
"description": "Short checkout.",
"organisation": {
"$ref": "https://ils.rero.ch/api/organisations/1"
}
},
"type": "standard"
},
{
"pid": "3",
Expand All @@ -24,7 +26,8 @@
"description": "On-site consultation.",
"organisation": {
"$ref": "https://ils.rero.ch/api/organisations/1"
}
},
"type": "standard"
},
{
"pid": "4",
Expand All @@ -33,7 +36,8 @@
"description": "No checkout.",
"organisation": {
"$ref": "https://ils.rero.ch/api/organisations/1"
}
},
"type": "standard"
},
{
"pid": "5",
Expand All @@ -42,7 +46,8 @@
"description": "Standard checkout for adults only (16+).",
"organisation": {
"$ref": "https://ils.rero.ch/api/organisations/1"
}
},
"type": "standard"
},
{
"pid": "6",
Expand All @@ -51,7 +56,8 @@
"description": "Short checkout for adults only (16+).",
"organisation": {
"$ref": "https://ils.rero.ch/api/organisations/1"
}
},
"type": "standard"
},
{
"pid": "7",
Expand All @@ -60,7 +66,8 @@
"description": "Standard checkout.",
"organisation": {
"$ref": "https://ils.rero.ch/api/organisations/2"
}
},
"type": "standard"
},
{
"pid": "8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,29 @@
"key": "description"
}
]
},
{
"type": "fieldset",
"items": [
{
"key": "type",
"type": "select-item-type-type",
"required": true,
"validationMessage": {
"alreadyTakenMessage": "There is already an online type for your organisation"
},
"titleMap": [
{
"value": "standard",
"name": "Standard"
},
{
"value": "online",
"name": "Online"
}
],
"default": "standard"
}
]
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"$schema",
"pid",
"name",
"organisation"
"organisation",
"type"
],
"properties": {
"$schema": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"title": "Library",
"key": "library.$ref",
"type": "select",
"remoteRecordType": "libraries",
"readonly": true
"remoteRecordType": "libraries"
}
]
},
Expand All @@ -33,15 +32,30 @@
]
},
{
"key": "is_pickup",
"type": "checkbox"
},
{
"key": "is_online",
"type": "checkbox"
"type": "fieldset",
"items": [
{
"key": "is_pickup",
"type": "checkbox"
},
{
"key": "pickup_name",
"condition": "model.is_pickup"
}
]
},
{
"key": "pickup_name",
"condition": "model.is_pickup"
"type": "fieldset",
"items": [
{
"key": "is_online",
"notitle": true,
"type": "checkbox-is-online",
"label": "Is Online",
"validationMessage": {
"alreadyTakenMessage": "The \"online\" type must be unique per library"
}
}
]
}
]
18 changes: 12 additions & 6 deletions tests/data/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,8 @@
"description": "Standard checkout.",
"organisation": {
"$ref": "https://ils.rero.ch/api/organisations/org1"
}
},
"type": "standard"
},
"itty2": {
"$schema": "https://ils.rero.ch/schema/item_types/item_type-v0.0.1.json",
Expand All @@ -666,7 +667,8 @@
"description": "On-site consultation.",
"organisation": {
"$ref": "https://ils.rero.ch/api/organisations/org1"
}
},
"type": "standard"
},
"itty3": {
"$schema": "https://ils.rero.ch/schema/item_types/item_type-v0.0.1.json",
Expand All @@ -675,7 +677,8 @@
"description": "Specific rules.",
"organisation": {
"$ref": "https://ils.rero.ch/api/organisations/org1"
}
},
"type": "standard"
},
"itty4": {
"$schema": "https://ils.rero.ch/schema/item_types/item_type-v0.0.1.json",
Expand All @@ -684,7 +687,8 @@
"description": "Regular checkout.",
"organisation": {
"$ref": "https://ils.rero.ch/api/organisations/org2"
}
},
"type": "standard"
},
"itty5": {
"$schema": "https://ils.rero.ch/schema/item_types/item_type-v0.0.1.json",
Expand All @@ -693,7 +697,8 @@
"description": "Internal consultation.",
"organisation": {
"$ref": "https://ils.rero.ch/api/organisations/org2"
}
},
"type": "standard"
},
"itty6": {
"$schema": "https://ils.rero.ch/schema/item_types/item_type-v0.0.1.json",
Expand All @@ -702,7 +707,8 @@
"description": "Particular rules.",
"organisation": {
"$ref": "https://ils.rero.ch/api/organisations/org2"
}
},
"type": "standard"
},
"itty7": {
"$schema": "https://ils.rero.ch/schema/item_types/item_type-v0.0.1.json",
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/item_types/test_item_types_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_item_type_create(db, item_type_data_tmp, org_martigny,
with pytest.raises(RecordValidationError):
itty = ItemType.create(item_type_data_tmp, delete_pid=True)

del item_type_data_tmp['type']
item_type_data_tmp['type'] = 'standard'
itty = ItemType.create(item_type_data_tmp, delete_pid=True)

assert itty == item_type_data_tmp
Expand Down
5 changes: 5 additions & 0 deletions ui/src/app/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ export function cleanDictKeys(data: any) {
export function _(str: string) {
return str;
}

export function extractIdOnRef(ref: string) {
const rx = /.*\/?(.+)$/ig;
return rx.exec(ref)[1];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!--

RERO ILS
Copyright (C) 2019 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/>.

-->
<label
[attr.for]="'control' + layoutNode?._id"
[class]="options?.itemLabelHtmlClass || ''">
<input *ngIf="boundControl"
[formControl]="formControl"
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
[id]="'control' + layoutNode?._id"
[name]="controlName"
[readonly]="options?.readonly ? 'readonly' : null"
type="checkbox">
<input *ngIf="!boundControl"
[attr.aria-describedby]="'control' + layoutNode?._id + 'Status'"
[checked]="isChecked ? 'checked' : null"
[disabled]="controlDisabled"
[id]="'control' + layoutNode?._id"
[name]="controlName"
[readonly]="options?.readonly ? 'readonly' : null"
[value]="controlValue"
type="checkbox"
(change)="updateValue($event)">
<span *ngIf="options?.label"
[style.display]="options?.nolabel ? 'none' : ''"
[class]="options?.label ? 'ml-2' : ''"
[innerHTML]="options?.label"></span>
</label>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*

RERO ILS
Copyright (C) 2019 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/>.

*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*

RERO ILS
Copyright (C) 2019 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 { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { CheckboxIsOnlineComponent } from './checkbox-is-online.component';

describe('CheckboxIsOnlineComponent', () => {
let component: CheckboxIsOnlineComponent;
let fixture: ComponentFixture<CheckboxIsOnlineComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CheckboxIsOnlineComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(CheckboxIsOnlineComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Loading