All files / src/fieldcontrols NameField.ts

100% Statements 10/10
100% Branches 5/5
100% Functions 2/2
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40            1x 1x 1x 1x                         1x           1x 11x       4x            
/**
 * @module FieldControls
 * 
 */ /** */
 
import { FieldSettings } from 'sn-client-js';
import { autoinject, computedFrom } from 'aurelia-framework';
import { FieldBaseControl } from './FieldBaseControl';
import { customElement } from 'aurelia-templating';
import { MDCTextField } from '@material/textfield/dist/mdc.textfield';
 
 
/**
 * Field control for Content name.
 * Usage:
 * 
 * ``` html
 * <name-field content.bind="content" settings.bind="myShortTextFieldSettings"></name-field>
 * ```
 */
@autoinject
@customElement('name-field')
export class NameField extends FieldBaseControl<string, FieldSettings.ShortTextFieldSetting> {
 
    textfield: HTMLElement;
    mdcTextField: MDCTextField;
 
    @computedFrom('content')
    get parentPath(): string{
        return this.content && (this.content.IsSaved ? this.content.ParentPath : this.content.Path) || '';
    }
 
    attached() {
        this.mdcTextField = new MDCTextField(this.textfield);
    }
 
 
}