Skip to content

Commit

Permalink
form options: item type and location
Browse files Browse the repository at this point in the history
* Adds custom widgets
* Adds a new column "type" on item_type
* Adds a new column "is_online" on location

Co-Authored-by: Bertrand Zuchuat <[email protected]>
Co-Authored-by: Alicia Zangger <[email protected]>
  • Loading branch information
Garfield-fr and Alicia Zangger committed Sep 27, 2019
1 parent 9563386 commit ad24fdc
Show file tree
Hide file tree
Showing 16 changed files with 500 additions and 28 deletions.
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": "Only one location per library for online status"
}
}
]
}
]
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
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

0 comments on commit ad24fdc

Please sign in to comment.