You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2018/04/25 14:01:58 UTC
[airavata-django-portal] 01/02: AIRAVATA-2611 InputEditorMixin
refactor
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 0177a607777b3eb78930362fd6a123953aa658cf
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Mon Apr 23 13:28:06 2018 -0400
AIRAVATA-2611 InputEditorMixin refactor
---
.../experiment/input-editors/FileInputEditor.vue | 60 +---------------------
.../experiment/input-editors/StringInputEditor.vue | 56 ++------------------
2 files changed, 5 insertions(+), 111 deletions(-)
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/FileInputEditor.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/FileInputEditor.vue
index 4efa9b1..34f8c4b 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/FileInputEditor.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/FileInputEditor.vue
@@ -9,65 +9,9 @@
</template>
<script>
-import {models} from 'django-airavata-api'
+import InputEditorMixin from './InputEditorMixin'
export default {
name: 'file-input-editor',
- props: {
- value: {
- required: false,
- },
- 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();
- }
+ mixins: [InputEditorMixin],
}
</script>
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/StringInputEditor.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/StringInputEditor.vue
index 4a3a96a..3063896 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/StringInputEditor.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/StringInputEditor.vue
@@ -9,66 +9,16 @@
</template>
<script>
-import {models} from 'django-airavata-api'
+import InputEditorMixin from './InputEditorMixin'
+
export default {
name: 'string-input-editor',
+ mixins: [InputEditorMixin],
props: {
value: {
type: String,
- required: false,
- },
- 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();
- }
}
</script>
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
machristie@apache.org.