All files / src FieldSettings.ts

100% Statements 46/46
100% Branches 14/14
100% Functions 8/8
100% Lines 23/23
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160                                      1x       1x       1x       1x       1x       1x       1x     1x 174888x     1x                                       1x               1x           1x         1x       1x             1x         1x                   1x           1x                   1x                   1x             1x               1x      
/**
 * @module FieldSettings
 * @preferred
 *
 * @description Module for FieldSettings.
 *
 * FieldSetting object is the implementation of the configuration element in a Sense/Net Content Type Definition.
 * The FieldSetting of a Field contains properties that define the behavior of the Field - for example a Field can be configured as read only or compulsory to fill.
 * FieldSettings helps us to autogenerate type and schema TS files from Sense/Net CTDs and use these files to reach all the configuration options of the Content Types fields on
 * client-side e.g. for validation.
 *
 * This module also contains some FieldSetting related enums to use them as types in properties e.g. visibitily or datetime mode options.
 */ /** */
 
import { ComplexTypes } from './SN';
 
    /**
     * Enum for Field visibility values.
     */
export enum FieldVisibility { Show, Hide, Advanced }
    /**
     * Enum for Field output method values.
     */
export enum OutputMethod { Default, Raw, Text, Html }
    /**
     * Enum for Choice Field control values.
     */
export enum DisplayChoice { DropDown, RadioButtons, CheckBoxes }
    /**
     * Enum for DateTime Field mode values.
     */
export enum DateTimeMode { None, Date, DateAndTime }
    /**
     * Enum for DateTime Field precision values.
     */
export enum DateTimePrecision { Millisecond, Second, Minute, Hour, Day }
    /**
     * Enum for LongText field editor values.
     */
export enum TextType { LongText, RichText, AdvancedRichText }
    /**
     * Enum for HyperLink field href values.
     */
export enum UrlFormat { Hyperlink, Picture }
 
// tslint:disable-next-line:only-arrow-functions
export function isFieldSettingOfType<T extends FieldSetting>(setting: FieldSetting, type: {new(): T}): setting is T {
    return setting.Type === type.name;
}
 
export class FieldSetting {
        public Name: string;
        public Type: string;
        public DisplayName?: string;
        public Description?: string;
        public Icon?: string;
        public ReadOnly?: boolean;
        public Compulsory?: boolean;
        public DefaultValue?: string;
        public OutputMethod?: OutputMethod;
        public VisibleBrowse?: FieldVisibility;
        public VisibleNew?: FieldVisibility;
        public VisibleEdit?: FieldVisibility;
        public FieldIndex?: number;
        public DefaultOrder?: number;
        public ControlHint?: string;
 
    }
 
    // Used in ContentType, GenericContent, File, Image, TrashBag, TrashBin, Task
export class IntegerFieldSetting extends FieldSetting {
        public MinValue?: number;
        public MaxValue?: number;
        public ShowAsPercentage?: boolean;
        public Step?: number;
    }
 
    //
export class TextFieldSetting extends FieldSetting {
        public MinLength?: number;
        public MaxLength?: number;
    }
 
    // Used in ContentType, GenericContent, File, ContentList, Device, Domain, Email, OrganizationalUnit, TrashBag, Group, Task, User
export class ShortTextFieldSetting extends TextFieldSetting {
        public Regex?: string;
    }
 
    // Used in ContentType, GenericContent, Settings, IndexingSettings, ContentList, Workspace, Site, CustomListItem, User
export class NullFieldSetting extends FieldSetting {
    }
 
    // Used in ContentType, GenericContent, File, HtmlTemplate, Image, ContentList, Aspect, Email, SmartFolder, Query, User
export class LongTextFieldSetting extends TextFieldSetting {
        public Rows?: number;
        public TextType?: TextType;
        public AppendModifications?: boolean;
    }
 
    // Used in ContentType, File, User
export class BinaryFieldSetting extends FieldSetting {
        public IsText?: boolean;
    }
 
    // Used in ContentType, GenericContent, ContentLink, ContentList, ImageLibrary, TrashBag, Workspace, Site, UserProfile, Group, Memo, Task, User
export class ReferenceFieldSetting extends FieldSetting {
        public AllowMultiple?: boolean;
        public AllowedTypes?: string[];
        public SelectionRoots?: string[];
        public Query?: string;
        public FieldName?: string;
 
    }
 
    // Used in ContentType, GenericContent, Image, Domain, Email, OrganizationalUnit, TrashBag, Workspace, Group, Memo, Task, User
export class DateTimeFieldSetting extends FieldSetting {
        public DateTimeMode?: DateTimeMode;
        public Precision?: DateTimePrecision;
    }
 
    // Used in GenericContent, ContentList, SmartFolder, Site, Memo, Task, Query, User
export class ChoiceFieldSetting extends ShortTextFieldSetting {
        public AllowExtraValue?: boolean;
        public AllowMultiple?: boolean;
        public Options?: ComplexTypes.ChoiceOption[];
        public DisplayChoice?: DisplayChoice;
        public EnumTypeName?: string;
 
    }
 
    // Used in GenericContent, File, Resource
export class NumberFieldSetting extends FieldSetting {
        public MinValue?: number;
        public MaxValue?: number;
        public Digits?: number;
        public ShowAsPercentage?: boolean;
        public Step?: number;
 
    }
 
    // Used in GenericContent
export class RatingFieldSetting extends ShortTextFieldSetting {
        public Range?: number;
        public Split?: number;
 
    }
 
    // Used in User
export class PasswordFieldSetting extends ShortTextFieldSetting {
        public ReenterTitle?: string;
        public ReenterDescription?: string;
        public PasswordHistoryLength?: number;
 
    }
 
    // Used in User
export class CaptchaFieldSetting extends FieldSetting {
 
    }