}
disassociateMaterials(courses) {
+ const deleteRequest$ = [];
+
return new Promise((resolve, reject) => {
const course_ids = [];
const course_library_hash = {};
course_ids.push(course.id());
course_library_hash[course.id()] = course.owning_lib();
});
- this.pcrud.search('acmcm', {course: course_ids}).subscribe(material => {
- material.isdeleted(true);
- this.resetItemFields(material, course_library_hash[material.course()]);
- this.pcrud.autoApply(material).subscribe(() => {
+
+ this.pcrud.retrieveAll('acmcm', {course: course_ids}).subscribe(material => {
+ deleteRequest$.push(this.net.request(
+ 'open-ils.courses', 'open-ils.courses.detach_material',
+ this.auth.token(), material.id()));
+ }, err => {
+ reject(err);
+ }, () => {
+ merge(...deleteRequest$).subscribe(val => {
+ console.log(val);
}, err => {
reject(err);
}, () => {
- resolve(material);
+ resolve(courses);
});
- }, err => {
- reject(err);
- }, () => {
- resolve(courses);
});
});
}
+ detachMaterials(materials) {
+ const deleteRequest$ = [];
+ materials.forEach(material => {
+ deleteRequest$.push(this.net.request(
+ 'open-ils.courses', 'open-ils.courses.detach_material',
+ this.auth.token(), material.id()));
+ });
+
+ return deleteRequest$;
+ }
+
disassociateUsers(user) {
return new Promise((resolve, reject) => {
const user_ids = [];
});
}
- resetItemFields(material, course_lib) {
- this.pcrud.retrieve('acp', material.item(),
- {flesh: 3, flesh_fields: {acp: ['call_number']}}).subscribe(copy => {
- if (material.original_status()) {
- copy.status(material.original_status());
- }
- if (copy.circ_modifier() !== material.original_circ_modifier()) {
- copy.circ_modifier(material.original_circ_modifier());
- }
- if (material.original_location()) {
- copy.location(material.original_location());
- }
- if (material.original_callnumber()) {
- this.pcrud.retrieve('acn', material.original_callnumber()).subscribe(cn => {
- this.updateItem(copy, course_lib, cn.label(), true);
- });
- } else {
- this.updateItem(copy, course_lib, copy.call_number().label(), false);
- }
- });
- }
-
updateItem(item: IdlObject, courseLib: IdlObject, callNumber: string, updatingVolume: boolean) {
const cn = item.call_number();