Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
42 lines (34 sloc) 832 Bytes
import { Component, Attribute, Input, Output, Optional } from "../angular-decorators";
import template from "../templates/editableField.html";
@Component("editableField", { template })
export class EditableField
{
@Input() fieldValue;
@Optional() @Attribute() fieldType;
@Output() onUpdate;
editMode = false;
fieldValueCopy;
$onInit()
{
// Make a copy of the initial value to be able to reset it later
this.fieldValueCopy = this.fieldValue;
// Set a default fieldType
if (!this.fieldType)
{
this.fieldType = 'text';
}
}
handleModeChange()
{
if (this.editMode)
{
this.onUpdate({ value: this.fieldValue });
this.fieldValueCopy = this.fieldValue;
}
this.editMode = !this.editMode;
};
reset()
{
this.fieldValue = this.fieldValueCopy;
};
}
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.