Skip to content

Commit

Permalink
items: acquisition default date is optional
Browse files Browse the repository at this point in the history
For new issue item, the acquisition date should not be set by default to
the current date. This field must be empty (this change automatically
disable the 'new acquisition' toggle in the item editor).

Closes rero/rero-ils#1449

Co-authored-by: Renaud Michotte <renaud.michotte@gmail.com>
  • Loading branch information
zannkukai committed Nov 25, 2020
1 parent 1955d44 commit 41f38ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions projects/admin/src/app/class/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ export class ItemNote {
content: string;
}

export enum ItemType {
STANDARD = 'standard',
ISSUE = 'issue'
}

export class Item {

static PUBLIC_NOTE_TYPES: ItemNoteType[] = [
Expand Down
7 changes: 5 additions & 2 deletions projects/admin/src/app/routes/items-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { Record } from '@rero/ng-core/lib/record/record';
import { JSONSchema7 } from 'json-schema';
import { of } from 'rxjs';
import { map } from 'rxjs/operators';
import { ItemType } from '../class/items';
import { CanUpdateGuard } from '../guard/can-update.guard';
import { ItemsBriefViewComponent } from '../record/brief-view/items-brief-view/items-brief-view.component';
import { ItemDetailViewComponent } from '../record/detail-view/item-detail-view/item-detail-view.component';
Expand Down Expand Up @@ -75,7 +76,9 @@ export class ItemsRoute extends BaseRoute implements RouteInterface {
this._populateItemFieldFromHolding(record, holdingPid);
}
// for new item creation, fill the acquisition date field with the current timestamp
if (!record.hasOwnProperty('pid')) {
// issue should don't have the new acquisition date by default.
const recordType = ('type' in record) ? record.type : ItemType.STANDARD;
if (!record.hasOwnProperty('pid') && recordType !== ItemType.ISSUE) {
record.acquisition_date = this._routeToolService.datePipe.transform(Date.now(), 'yyyy-MM-dd');
}
return record;
Expand Down Expand Up @@ -232,7 +235,7 @@ export class ItemsRoute extends BaseRoute implements RouteInterface {
* @param holdingPid: the holding pid
*/
private _populateItemFieldFromHolding(record: any, holdingPid: string) {
record.type = 'issue';
record.type = ItemType.ISSUE;
record.issue = record.issue || {};
record.issue.regular = true; // default to true

Expand Down

0 comments on commit 41f38ac

Please sign in to comment.