Skip to content

Commit

Permalink
chore: Add ddm-pooled hook to ui/vue components.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico-AP committed Aug 28, 2023
1 parent f55cb58 commit cf0d53a
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 17 deletions.
2 changes: 1 addition & 1 deletion ddm/static/ddm/vue/css/vue_uploader.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ddm/static/ddm/vue/js/vue_uploader.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ddm/static/ddm/vue/js/vue_uploader.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions frontend/src/UploaderApp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
:blueprints="uploadConfig.blueprints"
:instructions="uploadConfig.instructions"
:exception-url="this.exceptionUrl"
:pooled="this.pooled"
@changedData="updatePostData"
></FileUploader>

Expand Down Expand Up @@ -72,6 +73,7 @@ export default {
actionUrl: String,
exceptionUrl: String,
language: String,
pooled: Boolean
},
data() {
this.$i18n.locale = this.language;
Expand Down
69 changes: 55 additions & 14 deletions frontend/src/components/FileUploader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
</div>
</div>

<template v-if="this.pooled === 'false'"> <!-- Check for ddm_pooled integration -->
<div class="row">
<div class="col feedback-col pb-5 pt-1">
<p class="fw-bold">{{ $t('donation-question') }}</p>
Expand All @@ -186,6 +187,7 @@
</div>
</div>
</div>
</template>

</template>

Expand Down Expand Up @@ -222,6 +224,29 @@
</template>
</div>
</div>

<!-- Part for ddm_pooled integration -->
<template v-if="this.pooled === 'true' && (uploadStatus === 'success' || uploadStatus === 'partial')">
<div class="row mt-5">
<div class="col feedback-col pb-5 pt-1">
<p class="fw-bold">{{ $t('pool-submit-question') }}</p>
<div class="consent-question-container">
<div class="question-choice-item">
<label class="form-check-label rb-cb-label" for="pool-donate-agree">
<input type="radio" id="pool-donate-agree" value="1" v-model="poolDonate" @change="emitToParent" required>
{{ $t('donation-agree-pooled') }}
</label>
</div>
<div class="question-choice-item">
<label class="form-check-label rb-cb-label" for="pool-donate-disagree">
<input type="radio" id="pool-donate-disagree" value="0" v-model="poolDonate" @change="emitToParent">
{{ $t('donation-disagree-pooled') }}
</label>
</div>
</div>
</div>
</div>
</template>
</div>
</div>

Expand Down Expand Up @@ -266,7 +291,8 @@ export default {
instructions: Array,
componentId: Number,
name: String,
exceptionUrl: String
exceptionUrl: String,
pooled: String
},
emits: ['changedData'],
data() {
Expand All @@ -276,7 +302,8 @@ export default {
uploadAttempts: 0,
generalErrors: [],
ulModalInfoMsg: '',
ulModalInfoTitle: ''
ulModalInfoTitle: '',
poolDonate: '0'
}
},
created() {
Expand Down Expand Up @@ -603,18 +630,32 @@ export default {
emitToParent() {
let dataToEmit = JSON.parse(JSON.stringify(this.blueprintData));
Object.keys(dataToEmit).forEach(key => {
if (dataToEmit[key].consent === '') {
dataToEmit[key].consent = null;
dataToEmit[key].extracted_data = [];
}
else if (dataToEmit[key].consent === 'false') {
dataToEmit[key].extracted_data = [];
dataToEmit[key].consent = false;
} else {
dataToEmit[key].consent = true;
}
})
if (this.pooled === 'false') {
Object.keys(dataToEmit).forEach(key => {
if (dataToEmit[key].consent === '') {
dataToEmit[key].consent = null;
dataToEmit[key].extracted_data = [];
}
else if (dataToEmit[key].consent === 'false') {
dataToEmit[key].extracted_data = [];
dataToEmit[key].consent = false;
} else {
dataToEmit[key].consent = true;
}
})
} else {
// Added for ddm_pooled integration.
let consent = this.poolDonate;
Object.keys(dataToEmit).forEach(key => {
if (consent === '0') {
dataToEmit[key].consent = false;
dataToEmit[key].extracted_data = [];
} else {
dataToEmit[key].consent = true;
}
})
}
this.$emit('changedData', dataToEmit);
},
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/translations/file_uploader.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"donation-question": "Do you agree to donate and submit the data listed above?",
"donation-agree": "Yes, I agree to submit these data",
"donation-disagree": "No, I do not want to submit these data",
"pool-submit-question": "Do you agree to submit these data and receive a personalized analysis?",
"donation-agree-pooled": "Yes, I agree to my data being analyzed",
"donation-disagree-pooled": "No, I do not want my data to be analyzed",
"extracted-data-intro": "The following data have been extracted and will be transmitted to the researchers with your consent",
"file": "file",
"error-multiple-files": "More than one file uploaded, but only one is expected.",
Expand Down Expand Up @@ -63,6 +66,9 @@
"donation-question": "Sind Sie damit einverstanden, diese Daten zu spenden?",
"donation-agree": "Ja, ich bin damit einverstanden, diese Daten zu spenden und an die Forschenden zu übermitteln.",
"donation-disagree": "Nein, ich möchte diese Daten nicht spenden.",
"pool-submit-question": "Sind Sie damit einverstanden Ihre Daten für eine personalisierte Auswertung zu übermitteln?",
"donation-agree-pooled": "Ja, ich bin damit einverstanden, meine Daten für eine personalisierte Auswertung zu übermitteln",
"donation-disagree-pooled": "Nein, ich möchte meine Daten nicht übermitteln",
"extracted-data-intro": "Die folgenden Daten wurden ausgelesen und werden bei Ihrer Zustimmung an die Forschenden übermittelt",
"file": "Datei",
"error-multiple-files": "Mehr als eine Datei hochgeladen, aber nur eine wird erwartet",
Expand Down

0 comments on commit cf0d53a

Please sign in to comment.