Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
n00rsy committed Oct 10, 2024
1 parent 28af7f7 commit 7b82b68
Showing 1 changed file with 115 additions and 50 deletions.
165 changes: 115 additions & 50 deletions static/src/components/setting/ownership_setting.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<template>
<div class="stats-config row">
<GigSpinner v-if="waiting" />
<div class="col-md-12" :style="waiting && 'opacity: 0.5'">
<div
class="col-md-12"
:style="waiting && 'opacity: 0.5'"
>
<div class="form-group row">
<div class="col-md-4">
<p> Project Owner </p>
Expand All @@ -17,11 +20,19 @@
<div class="col-md-8 pull-right">
<div v-if="Object.keys(coowners).length">
<p style="display: inline-block; word-break: normal; line-height: 35px;">
<span v-for="u in coowners" :key="u.name" class=" label label-lg label-info"
style="display: inline-block">
<span
v-for="u in coowners"
:key="u.name"
class=" label label-lg label-info"
style="display: inline-block"
>
{{ u.fullname }}
<i v-if="u.id !== owner.id" class="fa fa-times" aria-hidden="true"
@click="removeCoowner($event, u.id)" />
<i
v-if="u.id!==owner.id"
class="fa fa-times"
aria-hidden="true"
@click="removeCoowner($event, u.id)"
/>
</span>
</p>
</div>
Expand All @@ -33,18 +44,37 @@
</div>
<div class="col-md-8 pull-right">
<div class="input-group">
<input v-model="coownerQuery" type="text" class="form-control input-sm"
placeholder="Try with full name or nick name">
<input
v-model="coownerQuery"
type="text"
class="form-control input-sm"
placeholder="Try with full name or nick name"
>
<span class="input-group-append">
<button class="btn btn-sm btn-primary " @click="searchCoowners">
<button
class="btn btn-sm btn-primary "
@click="searchCoowners"
>
<i class="fa fa-search" />
Search
</button>
</span>
</div>
<div v-if="coownerResult.length" class="dropdown-content">
<div class="scroll" style="max-height: 150px;">
<div v-for="u in coownerResult" :key="u.id" :value="u" class="row" @click="addCoowner($event, u)">
<div
v-if="coownerResult.length"
class="dropdown-content"
>
<div
class="scroll"
style="max-height: 150px;"
>
<div
v-for="u in coownerResult"
:key="u.id"
:value="u"
class="row"
@click="addCoowner($event, u)"
>
<p> {{ u['fullname'] }} </p>
</div>
</div>
Expand All @@ -58,11 +88,19 @@
<div class="col-md-8 pull-right">
<div v-if="Object.keys(contacts).length">
<p style="display: inline-block; word-break: normal; line-height: 35px;">
<span v-for="u in contacts" :key="u.name" class=" label label-lg label-info"
style="display: inline-block">
<span
v-for="u in contacts"
:key="u.name"
class=" label label-lg label-info"
style="display: inline-block"
>
{{ u.fullname }}
<i v-if="u.id !== owner.id" class="fa fa-times" aria-hidden="true"
@click="removeContact($event, u.id)" />
<i
v-if="u.id!==owner.id"
class="fa fa-times"
aria-hidden="true"
@click="removeContact($event, u.id)"
/>
</span>
</p>
</div>
Expand All @@ -74,18 +112,37 @@
</div>
<div class="col-md-8 pull-right">
<div class="input-group">
<input v-model="contactQuery" type="text" class="form-control input-sm"
placeholder="Try with full name or nick name">
<input
v-model="contactQuery"
type="text"
class="form-control input-sm"
placeholder="Try with full name or nick name"
>
<span class="input-group-append">
<button class="btn btn-sm btn-primary " @click="searchContacts">
<button
class="btn btn-sm btn-primary "
@click="searchContacts"
>
<i class="fa fa-search" />
Search
</button>
</span>
</div>
<div v-if="contactResult.length" class="dropdown-content">
<div class="scroll" style="max-height: 150px;">
<div v-for="u in contactResult" :key="u.id" :value="u" class="row" @click="addContact($event, u)">
<div
v-if="contactResult.length"
class="dropdown-content"
>
<div
class="scroll"
style="max-height: 150px;"
>
<div
v-for="u in contactResult"
:key="u.id"
:value="u"
class="row"
@click="addContact($event, u)"
>
<p> {{ u['fullname'] }} </p>
</div>
</div>
Expand All @@ -95,15 +152,23 @@

<div class="form-group row">
<div class="col-md-4">
<p> {{ ownershipIdTitle }} </p>
<p> {{ ownership_id_title }} </p>
</div>
<div class="col-md-8 pull-right">
<input v-model="ownershipId" type="text" class="form-control input-sm" placeholder="Ownership ID">
<input
v-model="ownership_id"
type="text"
class="form-control input-sm"
placeholder="Ownership ID"
>
</div>
</div>

<div>
<button class="btn btn-sm btn-primary" @click="save">
<button
class="btn btn-sm btn-primary"
@click="save"
>
Save
</button>
</div>
Expand All @@ -120,7 +185,7 @@ export default {
GigSpinner
},
data() {
data () {
return {
owner: {},
coowners: {},
Expand All @@ -136,59 +201,59 @@ export default {
};
},
created() {
created () {
this.getData();
this.getOwnershipIdTitle()
this.getProjectId()
this.getOwnershipIdTitle();
this.getProjectId();
},
methods: {
initialize(data) {
initialize (data) {
this.coowners = this.getUsers(data.coowners_dict);
this.contacts = this.getUsers(data.contacts_dict);
this.owner = data.owner;
this.csrfToken = data.form.csrf;
},
getUsers(data) {
getUsers (data) {
let users = {};
data.forEach(function (u) {
users[u.id] = u;
});
return users;
},
getCoownersURL() {
getCoownersURL () {
let path = window.location.pathname;
let res = path.split('/');
res[res.length - 1] = 'coowners';
return res.join('/');
},
getProjectApiURL() {
return `/api/project/${this.projectId}`
getProjectApiURL () {
return `/api/project/${this.projectId}`;
},
getOwnershipIdTitle() {
let element = document.getElementById('ownership-id-title')
getOwnershipIdTitle () {
let element = document.getElementById('ownership-id-title');
if (element == null) {
window.pybossaNotify('An error occurred.', true, 'error');
return

Check failure on line 242 in static/src/components/setting/ownership_setting.vue

View workflow job for this annotation

GitHub Actions / build (16.x)

Missing semicolon

Check failure on line 242 in static/src/components/setting/ownership_setting.vue

View workflow job for this annotation

GitHub Actions / build (16.x)

Missing semicolon
}
this.ownershipIdTitle = element.innerText
this.ownershipIdTitle = element.innerText;
},
getProjectId() {
let element = document.getElementById('project-id')
getProjectId () {
let element = document.getElementById('project-id');
if (element == null) {
window.pybossaNotify('An error occurred.', true, 'error');
return

Check failure on line 251 in static/src/components/setting/ownership_setting.vue

View workflow job for this annotation

GitHub Actions / build (16.x)

Missing semicolon

Check failure on line 251 in static/src/components/setting/ownership_setting.vue

View workflow job for this annotation

GitHub Actions / build (16.x)

Missing semicolon
}
this.projectId = element.innerText
this.projectId = element.innerText;
},
async search(user, contact) {
async search (user, contact) {
// Reset and hide drop-downs with search results.
this.coownerResult = [];
this.contactResult = [];
Expand All @@ -214,7 +279,7 @@ export default {
return data['found'];
},
async getData() {
async getData () {
this.waiting = true;
try {
const res = await fetch(this.getCoownersURL(), {
Expand Down Expand Up @@ -247,31 +312,31 @@ export default {
}
},
addCoowner(event, ur) {
addCoowner (event, ur) {
Vue.set(this.coowners, ur.id, ur);
this.coowners[ur.id] = ur;
},
removeCoowner(event, id) {
removeCoowner (event, id) {
Vue.delete(this.coowners, id);
},
addContact(event, ur) {
addContact (event, ur) {
Vue.set(this.contacts, ur.id, ur);
this.contacts[ur.id] = ur;
},
removeContact(event, id) {
removeContact (event, id) {
Vue.delete(this.contacts, id);
},
validateOwnershipId() {
validateOwnershipId () {
let reg = new RegExp('^[0-9]+$');
return this.ownershipId.length == 0 ||

Check failure on line 335 in static/src/components/setting/ownership_setting.vue

View workflow job for this annotation

GitHub Actions / build (16.x)

Expected '===' and instead saw '=='

Check failure on line 335 in static/src/components/setting/ownership_setting.vue

View workflow job for this annotation

GitHub Actions / build (16.x)

Expected '===' and instead saw '=='
(reg.test(this.ownershipId) && this.ownershipId.length <= 20)
(reg.test(this.ownershipId) && this.ownershipId.length <= 20);
},
async searchCoowners() {
async searchCoowners () {
try {
if (this.coownerQuery) {
this.coownerResult = await this.search(this.coownerQuery);
Expand All @@ -283,7 +348,7 @@ export default {
}
},
async searchContacts() {
async searchContacts () {
try {
if (this.contactQuery) {
this.contactResult = await this.search(this.contactQuery, true);
Expand All @@ -295,7 +360,7 @@ export default {
}
},
async save() {
async save () {
if (!this.validateOwnershipId()) {
window.pybossaNotify(`${this.ownershipIdTitle} must be numeric and less than 20 characters!`, true, 'error');
return

Check failure on line 366 in static/src/components/setting/ownership_setting.vue

View workflow job for this annotation

GitHub Actions / build (16.x)

Missing semicolon

Check failure on line 366 in static/src/components/setting/ownership_setting.vue

View workflow job for this annotation

GitHub Actions / build (16.x)

Missing semicolon
Expand Down

0 comments on commit 7b82b68

Please sign in to comment.