# Pull Request Template <img width="1188" alt="image" src="https://github.com/user-attachments/assets/604fe991-3896-4e32-b227-7506b9939102" /> <img width="181" alt="image" src="https://github.com/user-attachments/assets/557c01ed-e91b-45ce-a658-008ec27aa5ff" /> <img width="175" alt="image" src="https://github.com/user-attachments/assets/5ecfb742-983a-44f1-8c94-143335318bc8" /> <img width="328" alt="image" src="https://github.com/user-attachments/assets/4a05f942-3afc-45d1-8005-129245b52cef" /> <img width="344" alt="image" src="https://github.com/user-attachments/assets/a3e5c85d-cd42-4368-b7aa-0422cdfe1c75" /> <img width="263" alt="image" src="https://github.com/user-attachments/assets/85821352-b8c2-407a-9808-c426b8dd7bfb" /> <img width="263" alt="image" src="https://github.com/user-attachments/assets/65fc0b98-c8a0-4f27-a648-3d250cd1c66d" />
156 lines
3.8 KiB
Vue
156 lines
3.8 KiB
Vue
<script>
|
|
import NextButton from 'dashboard/components-next/button/Button.vue';
|
|
import Thumbnail from 'dashboard/components/widgets/Thumbnail.vue';
|
|
|
|
export default {
|
|
components: {
|
|
NextButton,
|
|
Thumbnail,
|
|
},
|
|
props: {
|
|
agentList: {
|
|
type: Array,
|
|
default: () => [],
|
|
},
|
|
selectedAgents: {
|
|
type: Array,
|
|
default: () => [],
|
|
},
|
|
updateSelectedAgents: {
|
|
type: Function,
|
|
default: () => {},
|
|
},
|
|
isWorking: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
submitButtonText: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
},
|
|
data() {
|
|
return {};
|
|
},
|
|
computed: {
|
|
selectedAgentCount() {
|
|
return this.selectedAgents.length;
|
|
},
|
|
allAgentsSelected() {
|
|
return this.selectedAgents.length === this.agentList.length;
|
|
},
|
|
disableSubmitButton() {
|
|
return this.selectedAgentCount === 0;
|
|
},
|
|
},
|
|
methods: {
|
|
isAgentSelected(agentId) {
|
|
return this.selectedAgents.includes(agentId);
|
|
},
|
|
handleSelectAgent(agentId) {
|
|
const shouldRemove = this.isAgentSelected(agentId);
|
|
|
|
let result = [];
|
|
if (shouldRemove) {
|
|
result = this.selectedAgents.filter(item => item !== agentId);
|
|
} else {
|
|
result = [...this.selectedAgents, agentId];
|
|
}
|
|
|
|
this.updateSelectedAgents(result);
|
|
},
|
|
selectAllAgents() {
|
|
const result = this.agentList.map(item => item.id);
|
|
this.updateSelectedAgents(result);
|
|
},
|
|
agentRowClass(agentId) {
|
|
return { 'is-active': this.isAgentSelected(agentId) };
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<div>
|
|
<div class="add-agents__header" />
|
|
<table class="woot-table">
|
|
<thead>
|
|
<tr>
|
|
<td class="ltr:pl-2.5 rtl:pr-2.5">
|
|
<div class="flex items-center">
|
|
<input
|
|
name="select-all-agents"
|
|
type="checkbox"
|
|
:checked="allAgentsSelected ? 'checked' : ''"
|
|
:title="$t('TEAMS_SETTINGS.AGENTS.SELECT_ALL')"
|
|
@click.self="selectAllAgents"
|
|
/>
|
|
</div>
|
|
</td>
|
|
<td class="text-slate-800 dark:text-slate-100 ltr:pl-2.5 rtl:pr-2.5">
|
|
{{ $t('TEAMS_SETTINGS.AGENTS.AGENT') }}
|
|
</td>
|
|
<td class="text-slate-800 dark:text-slate-100 ltr:pl-2.5 rtl:pr-2.5">
|
|
{{ $t('TEAMS_SETTINGS.AGENTS.EMAIL') }}
|
|
</td>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr
|
|
v-for="agent in agentList"
|
|
:key="agent.id"
|
|
:class="agentRowClass(agent.id)"
|
|
>
|
|
<td class="w-12">
|
|
<div class="flex items-center">
|
|
<input
|
|
type="checkbox"
|
|
:checked="isAgentSelected(agent.id)"
|
|
@click.self="() => handleSelectAgent(agent.id)"
|
|
/>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<div class="flex items-center gap-2">
|
|
<Thumbnail
|
|
:src="agent.thumbnail"
|
|
size="24px"
|
|
:username="agent.name"
|
|
:status="agent.availability_status"
|
|
/>
|
|
<h4 class="text-base mb-0 text-slate-800 dark:text-slate-100">
|
|
{{ agent.name }}
|
|
</h4>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
{{ agent.email || '---' }}
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<div class="flex items-center justify-between mt-2">
|
|
<p>
|
|
{{
|
|
$t('TEAMS_SETTINGS.AGENTS.SELECTED_COUNT', {
|
|
selected: selectedAgents.length,
|
|
total: agentList.length,
|
|
})
|
|
}}
|
|
</p>
|
|
<NextButton
|
|
type="submit"
|
|
:label="submitButtonText"
|
|
:disabled="disableSubmitButton"
|
|
:is-loading="isWorking"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
input {
|
|
@apply mb-0;
|
|
}
|
|
</style>
|