some refactoring, fixed addEmployeeModal, played with scss

This commit is contained in:
Sockenklaus
2021-11-12 01:16:32 +01:00
parent 9334b1fa26
commit 8204135b0f
6 changed files with 39 additions and 44 deletions

View File

@@ -56,14 +56,15 @@ async function search() {
</script> </script>
<style scoped> <style lang="scss" scoped>
.form-check { .form-check {
padding-left: 20px; padding-left: 20px;
}
.form-check input { input {
margin-left: -0.5rem;
margin-right: 0.5rem; margin-right: 0.5rem;
margin-left: -0.5rem;
}
} }
</style> </style>

View File

@@ -31,11 +31,11 @@ div.modal.fade(
:key="i" :key="i"
@click="setResult(sugg)" @click="setResult(sugg)"
:class="{'active' : selected === i}" :class="{'active' : selected === i}"
) {{sugg.name}} ) {{sugg.last_name}}, {{sugg.first_name}}
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed, ref, watch, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import type { Ref } from 'vue' import type { Ref } from 'vue'
/** /**
@@ -67,8 +67,10 @@ div.modal.fade(
* Begin functions * Begin functions
*/ */
function filterResults(query : string) { function filterResults(query : string) {
suggestions.value = props.searchData.filter((el: { name: string }) => { console.log(props.searchData)
return el.name.toLowerCase().search(query.toLowerCase()) > -1 console.log(query)
suggestions.value = props.searchData.filter((el: { first_name: string, last_name: string }) => {
return (el.last_name+', '+el.first_name).toLowerCase().search(query.toLowerCase()) > -1
}) })
if(selected.value >= suggestions.value.length){ if(selected.value >= suggestions.value.length){
selected.value = suggestions.value.length - 1 selected.value = suggestions.value.length - 1
@@ -77,7 +79,7 @@ div.modal.fade(
function setResult(pResult : Employee) { function setResult(pResult : Employee) {
result.value = pResult result.value = pResult
query.value = pResult.name query.value = pResult.last_name+', '+pResult.first_name
isOpenSuggestions.value = false isOpenSuggestions.value = false
selected.value = 0 selected.value = 0
suggestions.value = [] suggestions.value = []
@@ -139,16 +141,16 @@ div.modal.fade(
}) })
</script> </script>
<style scoped> <style lang="scss" scoped>
li.dropdown-item:active,
li.dropdown-item.active {
background-color: #e9ecef;
color: #1e2125;
}
li.dropdown-item { li.dropdown-item {
cursor: pointer; cursor: pointer;
&.active, &:active {
background-color: #007bff;
color: #fff;
}
} }
</style> </style>

View File

@@ -24,7 +24,7 @@ AddEmployeeModal(
tr(v-for="(employee, eIndex) in row.employees" :key="eIndex") tr(v-for="(employee, eIndex) in row.employees" :key="eIndex")
td() td()
.row.justify-content-between.align-items-center.employee-wrapper .row.justify-content-between.align-items-center.employee-wrapper
.col.text-start.ps-3 {{employee.handle}} .col.text-start.ps-3 {{employee.shorthand}}
.col.text-end .col.text-end
button.btn.btn-sm( button.btn.btn-sm(
@click="removeEmployee(mIndex, rIndex, employee)" @click="removeEmployee(mIndex, rIndex, employee)"
@@ -66,7 +66,7 @@ AddEmployeeModal(
<script setup lang="ts"> <script setup lang="ts">
import { watch, computed, ref, onMounted } from 'vue' import { watch, computed, ref } from 'vue'
import type { Ref, ComputedRef } from 'vue' import type { Ref, ComputedRef } from 'vue'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useEmployees } from '@/stores/employees' import { useEmployees } from '@/stores/employees'
@@ -339,7 +339,7 @@ AddEmployeeModal(
</script> </script>
<style scoped> <style lang="scss" scoped>
table { table {
table-layout: fixed; table-layout: fixed;
-ms-user-select: none; -ms-user-select: none;
@@ -348,10 +348,11 @@ AddEmployeeModal(
-webkit-touch-callout: none; -webkit-touch-callout: none;
-khtml-user-select: none; -khtml-user-select: none;
user-select: none; user-select: none;
}
table td { td {
cursor: pointer; cursor: pointer;
} }
}
.o-acp__item.list-group-item:hover { .o-acp__item.list-group-item:hover {
background-color: aliceblue !important; background-color: aliceblue !important;
@@ -368,9 +369,6 @@ AddEmployeeModal(
} }
.selected { .selected {
/* border: 1px solid var(--bs-body-color) !important; */
/* border: var(--bs-primary); */
background-color: var(--bs-secondary); background-color: var(--bs-secondary);
opacity: 0.1; opacity: 0.1;
} }

View File

@@ -3,20 +3,6 @@ import axios from '@/axios'
import { useUser } from './user' import { useUser } from './user'
import { useNotifications } from './notifications' import { useNotifications } from './notifications'
type ResultData = {
id: number,
firstName: string,
lastName: string | undefined,
shorthand: string,
phone: string | undefined,
mobile: string | undefined,
email: string | undefined,
contractHours: number,
isActive: boolean,
username: string | undefined,
role: string
}
const user = useUser() const user = useUser()
const notifications = useNotifications() const notifications = useNotifications()
@@ -26,6 +12,7 @@ export const useEmployee = defineStore({
state: () => { state: () => {
return { return {
clean: { clean: {
/** @type Employee */
employee: { employee: {
id: NaN, id: NaN,
firstName: '', firstName: '',
@@ -42,6 +29,7 @@ export const useEmployee = defineStore({
}, },
}, },
/** @type Employee */
employee: { employee: {
id: NaN, id: NaN,
firstName: '', firstName: '',
@@ -72,7 +60,7 @@ export const useEmployee = defineStore({
this.$reset() this.$reset()
try { try {
const data : ResultData = await <ResultData>(await axios.get('employees/'+id, { const data : Employee = await <Employee>(await axios.get('employees/'+id, {
headers: user.header headers: user.header
})).data })).data

View File

@@ -4,9 +4,15 @@ type ScheduleData = [
type Employee = { type Employee = {
id: number, id: number,
name: string, first_name: string,
handle: string last_name: string,
email: string,
phone: string,
mobile: string,
role: string,
shorthand: string,
contractHours?: number contractHours?: number
username?: string
} }
type ScheduleRow = { type ScheduleRow = {

View File

@@ -18,5 +18,5 @@
"node" "node"
] ]
}, },
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "src/stores/employees.js"] "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
} }