UNPKG

graphdb-workbench

Version:
2 lines 4.08 kB
export const __webpack_id__=17268;export const __webpack_ids__=[868,3588,17268,22037,28379];export const __webpack_modules__={868:(e,t,s)=>{s.r(t),s.d(t,{DynamicFormField:()=>i});class i{_key="";_label="";_type="";_collection=!1;_value;_values;_regex;_required=!1;_group;hidden=!1;constructor(e){this._key=e.key,this._label=e.label,this._type=e.type,this._collection=e.collection,this._value=e.value,this._values=e.values,this._regex="string"==typeof e.regex?new RegExp(e.regex):e.regex,this._required=e.required,this._group=e.group,this.hidden=e.hidden}get key(){return this._key}set key(e){this._key=e}get label(){return this._label}set label(e){this._label=e}get type(){return this._type}set type(e){this._type=e}get collection(){return this._collection}set collection(e){this._collection=e}get value(){return this._value}set value(e){this._value=e}get values(){return this._values}set values(e){this._values=e}get regex(){return this._regex}set regex(e){this._regex="string"==typeof e?new RegExp(e):e}get required(){return this._required}set required(e){this._required=e}get group(){return this._group}set group(e){this._group=e}get hidden(){return this._hidden}set hidden(e){this._hidden=e}}},3588:(e,t,s)=>{s.r(t),s.d(t,{FIELD_TYPE:()=>i});const i={STRING:"string",TEXT:"text",BOOLEAN:"boolean",JSON:"json",SELECT:"select",MULTI_SELECT:"multi_select"}},17268:(e,t,s)=>{s.r(t),s.d(t,{dynamicFormModelMapper:()=>d});var i=s(38940),r=s(868),l=s(28379),n=s(22037),o=s(3588);const d=e=>{if(!e||!e.configs)return new n.DynamicFormModel;const t=u(e.configs);return _(t)},_=e=>{const t=[];return e.forEach(e=>{if(!e.group)return void t.push(e);let s=t.find(t=>t.groupId===e.group);s||(s=new n.DynamicFormGroup({groupId:e.group}),t.push(s)),(e.hidden?s.hiddenFields:s.fields).push(e)}),new n.DynamicFormModel(t)},u=e=>e.map(e=>{let t=a(e),s=e.values,r=[];return t!==o.FIELD_TYPE.MULTI_SELECT&&t!==o.FIELD_TYPE.SELECT||(s=s.map(t=>{const s=Array.isArray(e.value)&&e.value.indexOf(t)>-1||"string"==typeof e.value&&e.value===t,l=new i.SelectMenuOptionsModel({label:t,value:t,selected:s});return s&&r.push(l),l}),t===o.FIELD_TYPE.SELECT?e.value=r[0]?r[0]:[]:t===o.FIELD_TYPE.MULTI_SELECT&&(e.value=r)),h(e,t,s)}),h=(e,t,s)=>new r.DynamicFormField({key:e.key,label:e.label,description:e.description,type:t,collection:e.collection||!1,value:e.value,values:s,regex:e.regex,required:e.required||!1,group:e.group,hidden:e.hidden}),a=e=>{let t;return e.type===l.CONFIG_TYPE.TEXT?t=o.FIELD_TYPE.TEXT:e.type===l.CONFIG_TYPE.BOOLEAN?t=o.FIELD_TYPE.BOOLEAN:e.type===l.CONFIG_TYPE.JSON?t=o.FIELD_TYPE.JSON:e.type===l.CONFIG_TYPE.STRING&&(t=e.values&&e.values.length>0?e.collection?o.FIELD_TYPE.MULTI_SELECT:o.FIELD_TYPE.SELECT:o.FIELD_TYPE.STRING),t}},22037:(e,t,s)=>{s.r(t),s.d(t,{DynamicFormGroup:()=>r,DynamicFormModel:()=>i});class i{_models=[];constructor(e){this._models=e||[]}get models(){return this._models}set models(e){this._models=e}}class r{_groupId="";_fields=[];_hiddenFields=[];constructor(e){this._fields=e.fields||[],this._hiddenFields=e.hiddenFields||[],this._groupId=e.groupId||""}get fields(){return this._fields}set fields(e){this._fields=e}get hiddenFields(){return this._hiddenFields}set hiddenFields(e){this._hiddenFields=e}get groupId(){return this._groupId}set groupId(e){this._groupId=e}}},28379:(e,t,s)=>{s.r(t),s.d(t,{CONFIG_TYPE:()=>r,GraphqlEndpointConfigurationSettings:()=>l});var i=s(868);const r={STRING:"string",TEXT:"text",BOOLEAN:"boolean",JSON:"json"};class l{_settings;_hasSettings;constructor(e){this._settings=e,this._hasSettings=!!this._settings&&this._settings.models.length>0}toFlatJSON(){const e={},t=t=>{t.collection?e[t.key]=t.value:"select"===t.type?e[t.key]=t.value.value:e[t.key]=t.value};return this._settings.models.forEach(e=>{e instanceof i.DynamicFormField?t(e):[...e.fields,...e.hiddenFields].forEach(t)}),e}get hasSettings(){return this._hasSettings}get settings(){return this._settings}set settings(e){this._settings=e,this._hasSettings=this._settings.models.length>0}}}}; //# sourceMappingURL=17268.c9b54b2ec1f9960871a0.bundle.js.map