Skip to content

Commit

Permalink
Merge pull request #41 from seart-group/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dabico authored Jun 28, 2023
2 parents b63cf7d + 6f6d62b commit f5648c7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public ResponseEntity<?> requestAccess(@PathVariable UUID uuid, @AuthenticationP

User owner = task.getUser();
boolean isOwner = requester.equals(owner);
boolean isAdmin = Role.ADMIN == owner.getRole();
boolean isAdmin = Role.ADMIN == requester.getRole();
Status status = task.getStatus();
boolean isFinished = status == Status.FINISHED;
boolean canDownload = isFinished && (isOwner || isAdmin);
Expand Down
25 changes: 6 additions & 19 deletions dl4se-website/src/components/Counter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<script>
import useVuelidate from "@vuelidate/core"
import { between } from "@vuelidate/validators"
import { between, requiredIf } from "@vuelidate/validators"
export default {
name: "b-counter",
Expand All @@ -55,22 +55,11 @@ export default {
default: Number.MAX_SAFE_INTEGER
},
placeholder: String,
validators: {
type: Array,
default() {
return []
}
}
required: Boolean
},
computed: {
invalidParent() {
return this.validators
.map((validator) => validator.$invalid)
.reduce((curr, acc) => curr || acc, false)
},
state() {
if (this.invalidParent) return false
else if (this.v$.$dirty) return !this.v$.$invalid
if (this.v$.$dirty || this.required) return !this.v$.$invalid
else return null
},
counterClasses() {
Expand Down Expand Up @@ -99,14 +88,11 @@ export default {
} else {
this.count = this.min
}
},
resetValidation() {
if (this.count === null) this.v$.$reset()
}
},
watch: {
count() {
this.resetValidation()
if (!this.count) this.v$.$reset()
this.$emit("input", this.toNumberOrNull(this.count))
}
},
Expand All @@ -125,7 +111,8 @@ export default {
return {
count: {
$autoDirty: true,
between: between(this.min, this.max)
between: between(this.min, this.max),
required: requiredIf(this.required)
}
}
}
Expand Down
35 changes: 17 additions & 18 deletions dl4se-website/src/components/Masking.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<p class="masking-pad" />
<b-counter
:id="id + '-counter'"
class="py-2"
counter-class="masking-counter-input"
placeholder="%"
v-model.number="local.masking.percentage"
:min="1"
:max="100"
v-model.number="local.masking.percentage"
:validators="[v$.local.masking.percentage]"
:required="!!local.masking.token"
class="py-2"
counter-class="masking-counter-input"
/>
<p class="m-0">&nbsp;of&nbsp;</p>
<b-break />
Expand All @@ -23,7 +23,7 @@
placeholder="extra_id"
v-model.trim="local.masking.token"
@input="setToken"
:state="inputState"
:state="tokenState"
/>
</div>
<p class="m-0">&nbsp;token</p>
Expand Down Expand Up @@ -54,17 +54,20 @@ export default {
tokenSpecified() {
return this.local.masking.token != null
},
anyInputEmpty() {
return this.local.masking.percentage === null || this.local.masking.token === null
anySpecified() {
return !!this.percentageSpecified || !!this.tokenSpecified
},
bothInputsEmpty() {
return this.local.masking.percentage === null && this.local.masking.token === null
anyEmpty() {
return !this.local.masking.percentage || !this.local.masking.token
},
inputState() {
return this.v$.local.masking.$anyDirty ? !this.v$.local.masking.token.$invalid : null
bothEmpty() {
return !this.local.masking.percentage && !this.local.masking.token
},
tokenState() {
return this.anySpecified ? !this.v$.local.masking.token.$invalid : null
},
checkboxDisabled() {
return this.anyInputEmpty || this.v$.$invalid
return this.anyEmpty || this.v$.$invalid
}
},
methods: {
Expand All @@ -77,10 +80,10 @@ export default {
},
resetCheckbox() {
if (this.v$.$invalid) this.local.masking.contiguousOnly = false
if (this.bothInputsEmpty) this.local.masking.contiguousOnly = null
if (this.bothEmpty) this.local.masking.contiguousOnly = null
},
resetValidation() {
if (this.bothInputsEmpty) this.v$.$reset()
if (this.bothEmpty) this.v$.$reset()
}
},
watch: {
Expand Down Expand Up @@ -121,10 +124,6 @@ export default {
return {
local: {
masking: {
percentage: {
$autoDirty: true,
required: requiredIf(this.tokenSpecified)
},
token: {
$autoDirty: true,
required: requiredIf(this.percentageSpecified)
Expand Down

0 comments on commit f5648c7

Please sign in to comment.