From: Kyle Huckins Date: Tue, 22 Mar 2022 21:22:27 +0000 (+0000) Subject: Merge branch 'user/khuckins/lp1940105-archive-course-should-detach_material' into... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=497e84b14e34c9851ce725532f51d5547ef822a0;p=working%2FEvergreen.git Merge branch 'user/khuckins/lp1940105-archive-course-should-detach_material' into course-material-test-3 --- 497e84b14e34c9851ce725532f51d5547ef822a0 diff --cc Open-ILS/src/eg2/src/app/staff/share/course.service.ts index e6b6c18301,810db1781b..b93d7ca906 --- a/Open-ILS/src/eg2/src/app/staff/share/course.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/course.service.ts @@@ -194,57 -207,7 +209,35 @@@ export class CourseService }); }); } + + removeNonPublicUsers(courseID: Number) { + return new Promise((resolve, reject) => { + const acmcu_ids = []; + + this.getUsers([courseID]).subscribe(nonPublicUser => { + if(nonPublicUser && nonPublicUser.usr_role().is_public() !== 't') acmcu_ids.push(nonPublicUser.id()); + }, err => { + reject(err); + }, () => { + resolve(acmcu_ids); + if (acmcu_ids.length) { + this.pcrud.search('acmcu', {course: courseID, id: acmcu_ids}).subscribe(userToDelete => { + userToDelete.isdeleted(true); + this.pcrud.autoApply(userToDelete).subscribe(val => { + console.debug('deleted: ' + val); + }, err => { + console.log("Error: " + err); + reject(err); + }, () => { + console.log("Resolving"); + resolve(userToDelete); + }); + }); + } + }); + }); + } - 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, callNumber, updatingVolume) { return new Promise((resolve, reject) => {