mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
fix document detail date and tag editing
This commit is contained in:
parent
9089ed69c0
commit
9c996e69bb
@ -83,21 +83,9 @@
|
|||||||
<label for="exampleFormControlTextarea1">Tags</label>
|
<label for="exampleFormControlTextarea1">Tags</label>
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<div class="form-control">
|
<select multiple class="form-control" id="tags" formControlName="tags_id">
|
||||||
<span *ngFor="let tag of documentForm.value.tags">
|
<option *ngFor="let t of tags" [ngValue]="t.id">{{t.name}}</option>
|
||||||
<app-tag [tag]="tag" [clickable]="true" (click)="removeTag(tag)"></app-tag>
|
</select>
|
||||||
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group-append" ngbDropdown>
|
|
||||||
<button class="btn btn-outline-secondary" type="button" ngbDropdownToggle></button>
|
|
||||||
<div ngbDropdownMenu aria-labelledby="dropdownBasic1">
|
|
||||||
<button type="button" *ngFor="let tag of tags" ngbDropdownItem (click)="addTag(tag)">
|
|
||||||
<app-tag [tag]="tag"></app-tag>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<button class="btn btn-outline-secondary" type="button" (click)="createTag()">
|
<button class="btn btn-outline-secondary" type="button" (click)="createTag()">
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { DatePipe } from '@angular/common';
|
import { DatePipe, formatDate } from '@angular/common';
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { FormControl, FormGroup } from '@angular/forms';
|
import { FormControl, FormGroup } from '@angular/forms';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
@ -42,7 +42,7 @@ export class DocumentDetailComponent implements OnInit {
|
|||||||
correspondent_id: new FormControl(),
|
correspondent_id: new FormControl(),
|
||||||
document_type_id: new FormControl(),
|
document_type_id: new FormControl(),
|
||||||
archive_serial_number: new FormControl(),
|
archive_serial_number: new FormControl(),
|
||||||
tags: new FormControl([])
|
tags_id: new FormControl([])
|
||||||
})
|
})
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -84,7 +84,7 @@ export class DocumentDetailComponent implements OnInit {
|
|||||||
modal.componentInstance.success.subscribe(newTag => {
|
modal.componentInstance.success.subscribe(newTag => {
|
||||||
this.tagService.list().subscribe(tags => {
|
this.tagService.list().subscribe(tags => {
|
||||||
this.tags = tags.results
|
this.tags = tags.results
|
||||||
this.documentForm.get('tags_id').value.push(newTag.id)
|
this.documentForm.get('tags_id').setValue(this.documentForm.get('tags_id').value.concat([newTag.id]))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -126,23 +126,34 @@ export class DocumentDetailComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeTag(id: number) {
|
removeTag(id: number) {
|
||||||
var index = this.documentForm.value.tags.indexOf(id)
|
let index = this.documentForm.value.tags.indexOf(id)
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
this.documentForm.value.tags.splice(index, 1)
|
this.documentForm.value.tags.splice(index, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getDateCreated() {
|
||||||
|
let newDate = this.documentForm.value.created_date
|
||||||
|
let newTime = this.documentForm.value.created_time
|
||||||
|
return formatDate(newDate + "T" + newTime,"yyyy-MM-ddTHH:mm:ssZZZZZ", "en-us", "UTC")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
var newDocument = Object.assign(Object.assign({}, this.document), this.documentForm.value)
|
let newDocument = Object.assign(Object.assign({}, this.document), this.documentForm.value)
|
||||||
console.log(this.document)
|
|
||||||
console.log(newDocument)
|
newDocument.created = this.getDateCreated()
|
||||||
|
|
||||||
this.documentsService.update(newDocument).subscribe(result => {
|
this.documentsService.update(newDocument).subscribe(result => {
|
||||||
this.close()
|
this.close()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
saveEditNext() {
|
saveEditNext() {
|
||||||
var newDocument = Object.assign(Object.assign({}, this.document), this.documentForm.value)
|
let newDocument = Object.assign(Object.assign({}, this.document), this.documentForm.value)
|
||||||
|
|
||||||
|
newDocument.created = this.getDateCreated()
|
||||||
|
|
||||||
this.documentsService.update(newDocument).subscribe(result => {
|
this.documentsService.update(newDocument).subscribe(result => {
|
||||||
this.documentListViewService.getNext(this.document.id).subscribe(nextDocId => {
|
this.documentListViewService.getNext(this.document.id).subscribe(nextDocId => {
|
||||||
if (nextDocId) {
|
if (nextDocId) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user