This is an automated email from the ASF dual-hosted git repository. machristie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
commit af9df3c136d8f10f030f6d9f938d943aedd64895 Author: Marcus Christie <[email protected]> AuthorDate: Mon Apr 23 13:22:45 2018 -0400 AIRAVATA-2611 InputEditorMixin for common input editor functionality --- .../experiment/input-editors/InputEditorMixin.js | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/InputEditorMixin.js b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/InputEditorMixin.js new file mode 100644 index 0000000..cd56b99 --- /dev/null +++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/InputEditorMixin.js @@ -0,0 +1,63 @@ +// InputEditorMixin: mixin for experiment InputEditors, provides basic v-model +// and validation functionality and defines the basic props interface +// (experimentInput and experiment). +import {models} from 'django-airavata-api' +export default { + props: { + value: { + required: true, + }, + experiment: { + type: models.Experiment, + required: true, + }, + experimentInput: { + type: models.InputDataObjectType, + required: true, + }, + }, + data () { + return { + data: this.value, + inputHasBegun: false, + } + }, + computed: { + validationResults: function() { + return this.experimentInput.validate(this.experiment, this.data); + }, + valid: function() { + return Object.keys(this.validationResults).length === 0; + }, + validationFeedback: function() { + // Only display validation feedback after the user has provided + // input so that missing required value errors are only displayed + // after interacting with the input editor + return this.inputHasBegun && 'value' in this.validationResults + ? this.validationResults['value'] + : null; + }, + validationState: function() { + return this.inputHasBegun && 'value' in this.validationResults + ? 'invalid' + : null; + }, + }, + methods: { + valueChanged: function() { + this.inputHasBegun = true; + this.$emit('input', this.data); + this.checkValidation(); + }, + checkValidation: function() { + if (this.valid) { + this.$emit('valid'); + } else { + this.$emit('invalid'); + } + } + }, + mounted: function() { + this.checkValidation(); + } +} \ No newline at end of file -- To stop receiving notification emails like this one, please contact [email protected].
