OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/frontend/app/components/wp-fast-table/wp-table-editing.ts

43 lines
1.4 KiB

import {WorkPackageResourceInterface} from '../api/api-v3/hal-resources/work-package-resource.service';
import {WorkPackageEditForm} from "../wp-edit-form/work-package-edit-form";
import {TableRowEditContext} from "../wp-edit-form/table-row-edit-context";
import {WorkPackageEditingService} from "../wp-edit-form/work-package-editing-service";
import {$injectFields} from "../angular/angular-injector-bridge.functions";
export class WorkPackageTableEditingContext {
public wpEditing:WorkPackageEditingService;
constructor() {
$injectFields(this, 'wpEditing');
}
public forms:{[wpId:string]:WorkPackageEditForm} = {};
public reset() {
_.each(this.forms, (form) => form.destroy());
this.forms = {};
}
public stopEditing(workPackageId:string) {
this.wpEditing.stopEditing(workPackageId);
const existing = this.forms[workPackageId];
if (existing) {
existing.destroy();
delete this.forms[workPackageId];
}
}
public startEditing(workPackage:WorkPackageResourceInterface, classIdentifier:string):WorkPackageEditForm {
const wpId = workPackage.id;
const existing = this.forms[wpId];
if (existing) {
return existing;
}
// Get any existing edit state for this work package
const editContext = new TableRowEditContext(wpId, classIdentifier);
return this.forms[wpId] = WorkPackageEditForm.createInContext(editContext, workPackage, false);
}
}