{"version":3,"file":"rockField.js","sources":["../../../Framework/Controls/rockField.ts"],"sourcesContent":["// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\nimport { getFieldType } from \"@Obsidian/Utility/fieldTypes\";\r\nimport { computed, defineComponent, PropType, provide } from \"vue\";\r\nimport { PublicAttributeBag } from \"@Obsidian/ViewModels/Utility/publicAttributeBag\";\r\nimport { FieldType } from \"@Obsidian/SystemGuids/fieldType\";\r\n\r\nconst textField = getFieldType(FieldType.Text);\r\n\r\nexport default defineComponent({\r\n name: \"RockField\",\r\n props: {\r\n modelValue: {\r\n type: String as PropType,\r\n required: false\r\n },\r\n attribute: {\r\n type: Object as PropType,\r\n required: true\r\n },\r\n showEmptyValue: {\r\n type: Boolean as PropType,\r\n default: false\r\n },\r\n isEditMode: {\r\n type: Boolean as PropType,\r\n default: false\r\n },\r\n showLabel: {\r\n type: Boolean as PropType,\r\n default: true\r\n },\r\n isCondensed: {\r\n type: Boolean as PropType,\r\n default: false\r\n }\r\n },\r\n setup(props, { emit }) {\r\n const field = computed(() => {\r\n const fieldType = getFieldType(props.attribute.fieldTypeGuid ?? \"\");\r\n\r\n return fieldType ?? textField;\r\n });\r\n\r\n /** True if the read-only value should be displayed. */\r\n const showValue = computed(() => props.showEmptyValue || field.value?.getTextValue(props.modelValue ?? \"\", props.attribute.configurationValues ?? {}) !== \"\");\r\n\r\n /** True if this field is required and must be filled in. */\r\n const isRequired = computed(() => props.attribute.isRequired);\r\n\r\n /** Indicates to the editor component if this field is required or not. */\r\n const rules = computed(() => isRequired.value ? \"required\" : \"\");\r\n\r\n /** True if we are currently in edit mode. */\r\n const isEditMode = computed(() => props.isEditMode);\r\n\r\n /** The label to display above the value or editor. */\r\n const label = computed(() => props.attribute.name);\r\n\r\n /** The help text to display in the help bubble when in edit mode. */\r\n const helpText = computed(() => props.attribute.description);\r\n\r\n /** The read-only component to use to display the value. */\r\n const valueComponent = computed(() => {\r\n // This is here to cause the component to update reactively if\r\n // the value changes.\r\n // Commented out on 3/14/2022 by DSH. If no issues show up it can be removed\r\n // at a later point in time (maybe 6 months later). I do not believe this\r\n // is needed anymore after the refactoring that was performed.\r\n //const _ignored = props.attributeValue.value;\r\n\r\n return props.isCondensed\r\n ? field.value?.getCondensedFormattedComponent()\r\n : field.value?.getFormattedComponent();\r\n });\r\n\r\n /** The edit component to use to display the value. */\r\n const editComponent = computed(() => field.value?.getEditComponent());\r\n\r\n /** The value to display or edit. */\r\n const value = computed({\r\n get: () => props.modelValue || \"\",\r\n set(newValue) {\r\n emit(\"update:modelValue\", newValue);\r\n }\r\n });\r\n\r\n /** The configuration values for the editor component. */\r\n const configurationValues = computed(() => {\r\n return props.attribute.configurationValues ?? {};\r\n });\r\n\r\n provide(\"isRequired\", isRequired);\r\n\r\n return {\r\n label,\r\n showValue,\r\n valueComponent,\r\n rules,\r\n isEditMode,\r\n editComponent,\r\n value,\r\n helpText,\r\n configurationValues\r\n };\r\n },\r\n template: `\r\n
\r\n \r\n \r\n
\r\n
\r\n \r\n
`\r\n});\r\n"],"names":["textField","getFieldType","FieldType","Text","defineComponent","name","props","modelValue","type","String","required","attribute","Object","showEmptyValue","Boolean","default","isEditMode","showLabel","isCondensed","setup","_ref","emit","field","computed","_props$attribute$fiel","fieldType","fieldTypeGuid","showValue","_field$value","_props$modelValue","_props$attribute$conf","value","getTextValue","configurationValues","isRequired","rules","label","helpText","description","valueComponent","_field$value2","_field$value3","getCondensedFormattedComponent","getFormattedComponent","editComponent","_field$value4","getEditComponent","get","set","newValue","_props$attribute$conf2","provide","template"],"mappings":";;;;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