|
Lines 362-372
export const useCircRulesStore = defineStore("circRules", () => {
Link Here
|
| 362 |
}, |
362 |
}, |
| 363 |
async setAllRawRuleSets() { |
363 |
async setAllRawRuleSets() { |
| 364 |
const client = APIClient.circRule; |
364 |
const client = APIClient.circRule; |
| 365 |
try { |
365 |
await this.getAllRawRuleSets(); |
| 366 |
await this.getAllRawRuleSets(); |
366 |
|
| 367 |
} catch (e) { |
|
|
| 368 |
//TODO: handle e |
| 369 |
} |
| 370 |
this.currentAndDefaultRawRuleSets = [ |
367 |
this.currentAndDefaultRawRuleSets = [ |
| 371 |
...this.allCurrentLibraryRawRuleSets, |
368 |
...this.allCurrentLibraryRawRuleSets, |
| 372 |
...this.allDefaultLibraryRawRuleSets, |
369 |
...this.allDefaultLibraryRawRuleSets, |
|
Lines 399-418
export const useCircRulesStore = defineStore("circRules", () => {
Link Here
|
| 399 |
}, |
396 |
}, |
| 400 |
async getAllRawRuleSets() { |
397 |
async getAllRawRuleSets() { |
| 401 |
const client = APIClient.circRule; |
398 |
const client = APIClient.circRule; |
| 402 |
try { |
399 |
this.allDefaultLibraryRawRuleSets = await client.circ_rules.getAll( |
| 403 |
this.allDefaultLibraryRawRuleSets = |
400 |
{}, |
| 404 |
await client.circ_rules.getAll( |
401 |
{ library_id: "*", effective: false } |
| 405 |
{}, |
402 |
); |
| 406 |
{ library_id: "*", effective: false } |
403 |
this.allCurrentLibraryRawRuleSets = await client.circ_rules.getAll( |
| 407 |
); |
404 |
{}, |
| 408 |
this.allCurrentLibraryRawRuleSets = |
405 |
{ library_id: this.currentLibraryId, effective: false } |
| 409 |
await client.circ_rules.getAll( |
406 |
); |
| 410 |
{}, |
|
|
| 411 |
{ library_id: this.currentLibraryId, effective: false } |
| 412 |
); |
| 413 |
} catch (e) { |
| 414 |
throw e; |
| 415 |
} |
| 416 |
}, |
407 |
}, |
| 417 |
async getConfigurationOptions() { |
408 |
async getConfigurationOptions() { |
| 418 |
const client = APIClient.circRule; |
409 |
const client = APIClient.circRule; |
|
Lines 421-432
export const useCircRulesStore = defineStore("circRules", () => {
Link Here
|
| 421 |
}, |
412 |
}, |
| 422 |
async getItemTypes() { |
413 |
async getItemTypes() { |
| 423 |
const client = APIClient.item; |
414 |
const client = APIClient.item; |
| 424 |
let itemTypes = []; |
415 |
let itemTypes = await client.item_types.getAll(); |
| 425 |
try { |
416 |
|
| 426 |
itemTypes = await client.item_types.getAll(); |
|
|
| 427 |
} catch (e) { |
| 428 |
// TODO: handle e |
| 429 |
} |
| 430 |
itemTypes.unshift({ |
417 |
itemTypes.unshift({ |
| 431 |
item_type_id: "*", |
418 |
item_type_id: "*", |
| 432 |
description: $__("Default rule for all item types"), |
419 |
description: $__("Default rule for all item types"), |
|
Lines 436-446
export const useCircRulesStore = defineStore("circRules", () => {
Link Here
|
| 436 |
async getLibraries() { |
423 |
async getLibraries() { |
| 437 |
const client = APIClient.library; |
424 |
const client = APIClient.library; |
| 438 |
let libraries = []; |
425 |
let libraries = []; |
| 439 |
try { |
426 |
libraries = await client.libraries.getAll(); |
| 440 |
libraries = await client.libraries.getAll(); |
427 |
|
| 441 |
} catch (e) { |
|
|
| 442 |
// TODO: handle e |
| 443 |
} |
| 444 |
libraries.unshift({ |
428 |
libraries.unshift({ |
| 445 |
library_id: "*", |
429 |
library_id: "*", |
| 446 |
name: $__("Default rule for all libraries"), |
430 |
name: $__("Default rule for all libraries"), |
|
Lines 449-460
export const useCircRulesStore = defineStore("circRules", () => {
Link Here
|
| 449 |
}, |
433 |
}, |
| 450 |
async getPatronCategories() { |
434 |
async getPatronCategories() { |
| 451 |
const client = APIClient.patron; |
435 |
const client = APIClient.patron; |
| 452 |
let patronCategories = []; |
436 |
let patronCategories = await client.categories.getAll(); |
| 453 |
try { |
437 |
|
| 454 |
patronCategories = await client.categories.getAll(); |
|
|
| 455 |
} catch (e) { |
| 456 |
// TODO: handle e |
| 457 |
} |
| 458 |
patronCategories.unshift({ |
438 |
patronCategories.unshift({ |
| 459 |
patron_category_id: "*", |
439 |
patron_category_id: "*", |
| 460 |
name: $__("Default rule for all categories"), |
440 |
name: $__("Default rule for all categories"), |
|
Lines 466-485
export const useCircRulesStore = defineStore("circRules", () => {
Link Here
|
| 466 |
context.library_id = "*"; |
446 |
context.library_id = "*"; |
| 467 |
} |
447 |
} |
| 468 |
const client = APIClient.circRule; |
448 |
const client = APIClient.circRule; |
| 469 |
let result; |
449 |
const result = await client.circ_rules.getAll( |
| 470 |
try { |
450 |
{}, |
| 471 |
result = await client.circ_rules.getAll( |
451 |
{ |
| 472 |
{}, |
452 |
library_id: context.library_id, |
| 473 |
{ |
453 |
patron_category_id: context.patron_category_id, |
| 474 |
library_id: context.library_id, |
454 |
item_type_id: context.item_type_id, |
| 475 |
patron_category_id: context.patron_category_id, |
455 |
effective, |
| 476 |
item_type_id: context.item_type_id, |
456 |
} |
| 477 |
effective, |
457 |
); |
| 478 |
} |
|
|
| 479 |
); |
| 480 |
} catch (e) { |
| 481 |
throw e; |
| 482 |
} |
| 483 |
return result[0] ?? null; |
458 |
return result[0] ?? null; |
| 484 |
}, |
459 |
}, |
| 485 |
async updateCircRuleSets(existingRuleSet, triggerNumber) { |
460 |
async updateCircRuleSets(existingRuleSet, triggerNumber) { |
|
Lines 494-505
export const useCircRulesStore = defineStore("circRules", () => {
Link Here
|
| 494 |
existingRuleSet[`overdue_${triggerNumber}_mtt`]; |
469 |
existingRuleSet[`overdue_${triggerNumber}_mtt`]; |
| 495 |
circRuleSet[`overdue_${triggerNumber}_has_rules`] = |
470 |
circRuleSet[`overdue_${triggerNumber}_has_rules`] = |
| 496 |
existingRuleSet[`overdue_${triggerNumber}_has_rules`]; |
471 |
existingRuleSet[`overdue_${triggerNumber}_has_rules`]; |
| 497 |
try { |
472 |
const client = APIClient.circRule; |
| 498 |
const client = APIClient.circRule; |
473 |
await client.circ_rules.update(circRuleSet); |
| 499 |
await client.circ_rules.update(circRuleSet); |
|
|
| 500 |
} catch (e) { |
| 501 |
//TODO: handle e |
| 502 |
} |
| 503 |
}, |
474 |
}, |
| 504 |
...permissionsActions(store), |
475 |
...permissionsActions(store), |
| 505 |
}; |
476 |
}; |
| 506 |
- |
|
|