From 231f9907eb198eb250ae5af339d1f26811ecc56b Mon Sep 17 00:00:00 2001 From: Kyle Huckins Date: Wed, 9 Feb 2022 23:41:18 +0000 Subject: [PATCH] lp1922296 Course Materials Update Call Number Prefix/Suffix On Association - Update DB scripts to add Original Prefix and Suffix columns to Course Materials - Update fmIDL to add Original Prefix and Suffix properties to the Course Material IDL Object - Add Course Service function retrievePrefixSuffixList to retrieve all possible Callnumber Prefix and Suffixes - Add UI Entries for CN Prefix and Suffix on the Associate Materials Page Signed-off-by: Kyle Huckins --- Open-ILS/examples/fm_IDL.xml | 4 ++ .../course-associate-material.component.html | 44 ++++++++++++++++++++++ .../course-associate-material.component.ts | 18 +++++++++ .../src/eg2/src/app/staff/share/course.service.ts | 36 ++++++++++++++++-- Open-ILS/src/sql/Pg/040.schema.asset.sql | 2 + ...allnumber-prefix-suffix-on-item-association.sql | 9 +++++ 6 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX-lp19222960-update-callnumber-prefix-suffix-on-item-association.sql diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 6d8199f011..695180f11b 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -3312,12 +3312,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.html index aec9838d0b..5c2273738d 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.html @@ -78,6 +78,50 @@
+ +
+
+ + + + +
+
+ +
+
+
+ +
+
+
+
+ +
+
+ + + + +
+
+ +
+
+
+
+
+
+
+
Circulation Modifier
diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.ts index 9a8264cb8e..409501e1d7 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.ts @@ -44,15 +44,21 @@ export class CourseAssociateMaterialComponent extends DialogComponent implements @ViewChild('materialAddDifferentLibraryString', { static: true }) materialAddDifferentLibraryString: StringComponent; materialsDataSource: GridDataSource; + @Input() prefixList: any[] = []; + @Input() suffixList: any[] = []; @Input() barcodeInput: String; @Input() relationshipInput: String; @Input() tempCallNumber: String; + @Input() tempCallNumberPrefix: String; + @Input() tempCallNumberSuffix: String; @Input() tempStatus: Number; @Input() tempLocation: Number; @Input() tempCircMod: String; @Input() isModifyingStatus: Boolean; @Input() isModifyingCircMod: Boolean; @Input() isModifyingCallNumber: Boolean; + @Input() isModifyingCallNumberPrefix: Boolean; + @Input() isModifyingCallNumberSuffix: Boolean; @Input() isModifyingLocation: Boolean; bibId: number; @@ -84,6 +90,10 @@ export class CourseAssociateMaterialComponent extends DialogComponent implements } ngOnInit() { + let prefixSuffixList = this.course.retrievePrefixSuffixList(); + console.log(prefixSuffixList); + this.prefixList = prefixSuffixList.prefixList; + this.suffixList = prefixSuffixList.suffixList; this.associateBriefRecord = (newRecord: string) => { return this.net.request( 'open-ils.courses', @@ -164,6 +174,8 @@ export class CourseAssociateMaterialComponent extends DialogComponent implements barcode: barcode.trim(), relationship: relationship, isModifyingCallNumber: this.isModifyingCallNumber, + isModifyingCallNumberPrefix: this.isModifyingCallNumberPrefix, + isModifyingCallNumberSuffix: this.isModifyingCallNumberSuffix, isModifyingCircMod: this.isModifyingCircMod, isModifyingLocation: this.isModifyingLocation, isModifyingStatus: this.isModifyingStatus, @@ -182,6 +194,12 @@ export class CourseAssociateMaterialComponent extends DialogComponent implements item = associatedMaterial.item; let new_cn = item.call_number().label(); if (this.tempCallNumber) { new_cn = this.tempCallNumber; } + if (this.tempCallNumberPrefix) { + item.call_number().prefix(this.tempCallNumberPrefix); + } + if (this.tempCallNumberSuffix) { + item.call_number().suffix(this.tempCallNumberSuffix); + } this.course.updateItem(item, this.currentCourse.owning_lib(), new_cn, args.isModifyingCallNumber ).then(resp => { diff --git a/Open-ILS/src/eg2/src/app/staff/share/course.service.ts b/Open-ILS/src/eg2/src/app/staff/share/course.service.ts index 080626b8ef..3516045850 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/course.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/course.service.ts @@ -127,6 +127,14 @@ export class CourseService { if (args.isModifyingCallNumber) { material.original_callnumber(item.call_number()); } + if (args.isModifyingCallNumberPrefix) { + material.original_callnumber(item.call_number()); + material.original_callnumber_prefix(item.call_number().prefix()); + } + if (args.isModifyingCallNumberSuffix) { + material.original_callnumber(item.call_number()); + material.original_callnumber_suffix(item.call_number().suffix); + } const response = { item: item, material: this.pcrud.create(material).toPromise() @@ -195,7 +203,7 @@ export class CourseService { resetItemFields(material, course_lib) { this.pcrud.retrieve('acp', material.item(), - {flesh: 3, flesh_fields: {acp: ['call_number']}}).subscribe(copy => { + {flesh: 3, flesh_fields: {acp: ['call_number'], acn: ['prefix', 'suffix']}}).subscribe(copy => { if (material.original_status()) { copy.status(material.original_status()); } @@ -205,22 +213,43 @@ export class CourseService { if (material.original_location()) { copy.location(material.original_location()); } + if (material.original_callnumber_prefix()) { + copy.call_number().prefix(material.original_callnumber_prefix); + } + if (material.original_callnumber_suffix()) { + copy.call_number().suffix(material.original_callnumber_suffix); + } if (material.original_callnumber()) { this.pcrud.retrieve('acn', material.original_callnumber()).subscribe(cn => { - this.updateItem(copy, course_lib, cn.label(), true); + this.updateItem(copy, course_lib, cn, true); }); } else { - this.updateItem(copy, course_lib, copy.call_number().label(), false); + this.updateItem(copy, course_lib, copy.call_number(), false); } }); } + retrievePrefixSuffixList() { + const prefixList = []; + const suffixList = []; + this.pcrud.retrieveAll("acnp").subscribe(prefix => { + prefixList.push(prefix); + }); + this.pcrud.retrieveAll("acns").subscribe(suffix => { + suffixList.push(suffix); + }); + console.log(prefixList); + console.log(suffixList); + return {prefixList, suffixList}; + } + updateItem(item: IdlObject, courseLib, callNumber, updatingVolume) { return new Promise((resolve, reject) => { this.pcrud.update(item).subscribe(() => { if (updatingVolume) { const cn = item.call_number(); + console.log(cn); 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', @@ -241,6 +270,7 @@ export class CourseService { resolve(item); }); }, err => { + console.log(err); reject(err); }, () => { resolve(item); diff --git a/Open-ILS/src/sql/Pg/040.schema.asset.sql b/Open-ILS/src/sql/Pg/040.schema.asset.sql index e2692381ca..3b1d3334a2 100644 --- a/Open-ILS/src/sql/Pg/040.schema.asset.sql +++ b/Open-ILS/src/sql/Pg/040.schema.asset.sql @@ -1127,6 +1127,8 @@ CREATE TABLE asset.course_module_course_materials ( original_status INT REFERENCES config.copy_status, original_circ_modifier TEXT, --REFERENCES config.circ_modifier original_callnumber INT REFERENCES asset.call_number, + original_callnumber_prefix INT REFERENCES asset.call_number_prefix, + original_callnumber_suffix INT REFERENCES asset.call_number_suffix, unique (course, item, record) ); diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX-lp19222960-update-callnumber-prefix-suffix-on-item-association.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX-lp19222960-update-callnumber-prefix-suffix-on-item-association.sql new file mode 100644 index 0000000000..8422d352ce --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX-lp19222960-update-callnumber-prefix-suffix-on-item-association.sql @@ -0,0 +1,9 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +ALTER TABLE asset.course_module_course_materials + ADD COLUMN original_callnumber_prefix INT REFERENCES asset.call_number_prefix, + ADD COLUMN original_callnumber_suffix INT REFERENCES asset.call_number_suffix + +COMMIT; \ No newline at end of file -- 2.11.0