- Adds additional IDL/DB fields to Course Materials, holding Temporary Locaton, Circ Modifiers, Status, and Callnumbers
- Enables the editing of the above fields to apply to the linked copy
Signed-off-by: Kyle Huckins <khuckins@catalyte.io>
Changes to be committed:
modified: Open-ILS/examples/fm_IDL.xml
modified: Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.html
modified: Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.ts
modified: Open-ILS/src/eg2/src/app/staff/share/course.service.ts
modified: Open-ILS/src/perlmods/lib/OpenILS/Application/Courses.pm
modified: Open-ILS/src/sql/Pg/040.schema.asset.sql
new file: Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp1907927-edit-items-attached-to-course.sql
<field reporter:label="Original Circ Modifier" name="original_circ_modifier" reporter:datatype="link" />
<field reporter:label="Original Shelving Location" name="original_location" reporter:datatype="link" />
<field reporter:label="Original Callnumber" name="original_callnumber" reporter:datatype="link" />
+ <field reporter:label="Temporary Status" name="temporary_status" reporter:datatype="link" />
+ <field reporter:label="Temporary Circ Modifier" name="temporary_circ_modifier" reporter:datatype="link" />
+ <field reporter:label="Temporary Shelving Location" name="temporary_location" reporter:datatype="link" />
+ <field reporter:label="Temporary Callnumber" name="temporary_callnumber" reporter:datatype="link" />
</fields>
<links>
<link field="course" reltype="has_a" key="id" map="" class="acmc" />
<link field="original_status" reltype="has_a" key="id" map="" class="ccs" />
<link field="original_circ_modifier" reltype="has_a" key="code" map="" class="ccm" />
<link field="original_location" reltype="has_a" key="id" map="" class="acpl" />
+ <link field="temporary_callnumber" reltype="has_a" key="id" map="" class="acn" />
+ <link field="temporary_status" reltype="has_a" key="id" map="" class="ccs" />
+ <link field="temporary_circ_modifier" reltype="has_a" key="code" map="" class="ccm" />
+ <link field="temporary_location" reltype="has_a" key="id" map="" class="acpl" />
</links>
<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
<actions>
<eg-grid-column label="Barcode" i18n-label name="barcode" [cellTemplate]="barcodeCellTemplate"></eg-grid-column>
<eg-grid-column label="Title" i18n-label name="title" flex="3" [cellTemplate]="titleCellTemplate"></eg-grid-column>
<eg-grid-column path="item.call_number.label" label="Call Number" i18n-label></eg-grid-column>
+ <eg-grid-column path="temporary_callnumber.label" label="Call Number" i18n-label></eg-grid-column>
<eg-grid-column path="item.call_number.prefix.label" [hidden]="true" label="Call Number Prefix" i18n-label hidden>
</eg-grid-column>
<eg-grid-column path="item.call_number.suffix.label" [hidden]="true" label="Call Number Suffix" i18n-label hidden>
</eg-combobox>
</ng-template>
+<ng-template #TempCallNumberTemplate
+ let-field="field" let-record="record">
+ <div class="input-group">
+ <input type="text" class="form-control flex-grow-1"
+ [(ngModel)]="fmEditorTempCallNumber"
+ placeholder="Temporary Callnumber..." placeholder-i18n/>
+ </div>
+</ng-template>
+
<ng-container *ngIf="!isDialog()">
<!-- in "inline" mode, render the grid pane right here -->
<ng-container *ngTemplateOutlet="dialogContent">
</ng-container>
</ng-container>
-<eg-fm-record-editor #editDialog idlClass='acmcm' [fieldOptions]="{course: {customTemplate:{template:acmcTemplate}}}"
+<eg-fm-record-editor #editDialog idlClass='acmcm' [fieldOptions]="{
+ course: {customTemplate:{template:acmcTemplate}},
+ temporary_callnumber: {customTemplate:{template:TempCallNumberTemplate}}}"
[preloadLinkedValues]="true"
hiddenFields="id,item,original_callnumber,original_status,original_location,original_circ_modifier,record,temporary_record">
</eg-fm-record-editor>
materialsDataSource: GridDataSource;
@Input() barcodeInput: String;
@Input() relationshipInput: String;
+ @Input() fmEditorTempCallNumber: String;
@Input() tempCallNumber: String;
@Input() tempStatus: Number;
@Input() tempLocation: Number;
showEditDialog(courseMaterial: IdlObject): Promise<any> {
this.editDialog.mode = 'update';
this.editDialog.recordId = courseMaterial.id();
+ this.fmEditorTempCallNumber = courseMaterial.item().call_number().label();
return new Promise((resolve, reject) => {
+ courseMaterial.temporary_callnumber(this.fmEditorTempCallNumber);
this.editDialog.open({size: 'lg'}).subscribe(
result => {
this.materialEditSuccessString.current()
.then(str => this.toast.success(str));
this.pcrud.retrieve('acmcm', result).subscribe(material => {
- if (material.course() !== this.courseId) {
- this.materialsGrid.reload();
- } else {
- courseMaterial.relationship = material.relationship();
- }
+ this.course.editMaterialItem(material, this.currentCourse, this.fmEditorTempCallNumber).then(res => {
+ if (material.course() == this.courseId) {
+ courseMaterial.relationship = material.relationship();
+ courseMaterial.temporary_location = material.temporary_location();
+ courseMaterial.temporary_status = material.temporary_status();
+ courseMaterial.temporary_circ_modifier = material.temporary_circ_modifier();
+ courseMaterial['item.call_number.label'] = this.fmEditorTempCallNumber;
+ courseMaterial.item().call_number().label(this.fmEditorTempCallNumber);
+ }
+ });
+ }, err => {reject(err)}, () => {
+ resolve(result)
});
- resolve(result);
+ resolve(result)
+ this.materialsGrid.reload();
},
error => {
this.materialEditFailedString.current()
}
material.course(args.currentCourse.id());
if (args.relationship) { material.relationship(args.relationship); }
+
+ material.original_status(item.status());
+ material.original_location(item.location());
+ material.original_circ_modifier(item.circ_modifier());
+ material.original_callnumber(item.call_number());
// Apply temporary fields to the item
if (args.isModifyingStatus && args.tempStatus) {
- material.original_status(item.status());
+ material.temporary_status(args.tempStatus);
item.status(args.tempStatus);
}
if (args.isModifyingLocation && args.tempLocation) {
- material.original_location(item.location());
+ material.temporary_location(args.tempLocation);
item.location(args.tempLocation);
}
if (args.isModifyingCircMod) {
- material.original_circ_modifier(item.circ_modifier());
+ material.temporary_circ_modifier(args.tempCircMod);
item.circ_modifier(args.tempCircMod);
if (!args.tempCircMod) { item.circ_modifier(null); }
}
if (args.isModifyingCallNumber) {
- material.original_callnumber(item.call_number());
+ material.temporary_callnumber(args.tempCallNumber);
}
const response = {
item: item,
return response;
}
+ editMaterialItem(material, course, cn) {
+ let processed_copy;
+ let updateCallNumber = false;
+ return new Promise((resolve, reject) => {
+ return this.pcrud.retrieve('acp', material.item(),
+ {flesh: 3, flesh_fields: {acp: ['call_number']}}).subscribe(copy => {
+ if (material.temporary_circ_modifier()) {
+ copy.circ_modifier(material.temporary_circ_modifier());
+ }
+ if (material.temporary_status()) {
+ copy.status(material.temporary_status());
+ }
+ if (material.temporary_location()) {
+ copy.location(material.temporary_location());
+ }
+
+ if (cn != copy.call_number().label()) updateCallNumber = true;
+
+ return this.updateItem(copy, course.owning_lib(), cn, updateCallNumber)
+ .then(() => {
+ console.log("Item updated");
+ console.log(copy.call_number().label());
+ console.log(material.item());
+ });
+ },
+ err => reject(err),
+ () => {
+ resolve(processed_copy);
+ });
+ });
+ }
+
associateUsers(patron_id, args) {
const new_user = this.idl.create('acmcu');
if (args.role) { new_user.usr_role(args.role); }
if (updatingVolume) {
const cn = item.call_number();
const callNumberLibrary = this.org.canHaveVolumes(courseLib) ? courseLib.id() : cn.owning_lib();
- return this.net.request(
- 'open-ils.cat', 'open-ils.cat.call_number.find_or_create',
- this.auth.token(), callNumber, cn.record(),
- callNumberLibrary, cn.prefix(), cn.suffix(),
- cn.label_class()
- ).subscribe(res => {
- const event = this.evt.parse(res);
- if (event) { return; }
+ return new Promise ((resolve, reject) => {
return this.net.request(
- 'open-ils.cat', 'open-ils.cat.transfer_copies_to_volume',
- this.auth.token(), res.acn_id, [item.id()]
- ).subscribe(transfered_res => {
- console.debug('Copy transferred to volume with code ' + transfered_res);
+ 'open-ils.cat', 'open-ils.cat.call_number.find_or_create',
+ this.auth.token(), callNumber, cn.record(),
+ callNumberLibrary, cn.prefix(), cn.suffix(),
+ cn.label_class()
+ ).subscribe(res => {
+ const event = this.evt.parse(res);
+ if (event) { return; }
+ return this.net.request(
+ 'open-ils.cat', 'open-ils.cat.transfer_copies_to_volume',
+ this.auth.token(), res.acn_id, [item.id()]
+ ).subscribe(transfered_res => {
+ console.debug('Copy transferred to volume with code ' + transfered_res);
+ }, err => {
+ reject(err);
+ }, () => {
+ resolve(item);
+ });
}, err => {
reject(err);
}, () => {
resolve(item);
});
- }, err => {
- reject(err);
- }, () => {
- resolve(item);
});
} else {
this.pcrud.update(item).subscribe(() => {
my $fleshing = {
'flesh' => 2, 'flesh_fields' => {
'acmcm' => ['item', 'record', 'original_circ_modifier',
- 'original_location', 'original_status'],
+ 'original_location', 'original_status',
+ 'temporary_circ_modifier', 'temporary_location',
+ 'temporary_status', 'temporary_callnumber'],
'acp' => ['call_number', 'circ_lib', 'circ_modifier', 'location', 'status'],
'bre' => ['wide_display_entry'],
}
original_status INT REFERENCES config.copy_status,
original_circ_modifier TEXT, --REFERENCES config.circ_modifier
original_callnumber INT REFERENCES asset.call_number,
+ temporary_location INT REFERENCES asset.copy_location,
+ temporary_status INT REFERENCES config.copy_status,
+ temporary_circ_modifier TEXT, --REFERENCES config.circ_modifier
+ temporary_callnumber INT REFERENCES asset.call_number,
unique (course, item, record)
);
--- /dev/null
+BEGIN;\r
+\r
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);\r
+\r
+ALTER TABLE asset.course_module_course_materials\r
+ ADD COLUMN temporary_location INT REFERENCES asset.copy_location,\r
+ ADD COLUMN temporary_status INT REFERENCES config.copy_status,\r
+ ADD COLUMN temporary_circ_modifier TEXT, --REFERENCES config.circ_modifier\r
+ ADD COLUMN temporary_callnumber INT REFERENCES asset.call_number;\r
+\r
+COMMIT;
\ No newline at end of file