Skip to content

Commit 2208d31

Browse files
committed
Added Skill page + edit / delete
1 parent fc765c2 commit 2208d31

10 files changed

+156
-19
lines changed

.eslintrc.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"extends": "airbnb-base"
2+
"extends": ["airbnb-base", "plugin:vue/recommended"],
3+
"plugins": [
4+
"vue"
5+
]
36
}

package-lock.json

+34
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"start": "webpack-dev-server",
88
"build": "webpack",
9-
"lint": "eslint src",
9+
"lint": "eslint -c .eslintrc.json src",
1010
"test": "echo \"Error: no test specified\" && exit 1"
1111
},
1212
"author": "Julien LEICHER",
@@ -22,6 +22,7 @@
2222
"eslint": "^4.18.1",
2323
"eslint-config-airbnb-base": "^12.1.0",
2424
"eslint-plugin-import": "^2.8.0",
25+
"eslint-plugin-vue": "^4.3.0",
2526
"html-webpack-plugin": "^2.30.1",
2627
"node-sass": "^4.7.2",
2728
"sass-loader": "^6.0.6",

src/components/Pagebar.vue

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<template>
22
<div class="pagebar">
3-
<div>
4-
<h1 class="pagebar__title">{{title}} <small>{{subtitle}}</small></h1>
5-
</div>
3+
<h1 class="pagebar__title">{{title}} <small>{{subtitle}}</small></h1>
64
<div class="pagebar__actions">
75
<slot />
86
</div>
@@ -24,7 +22,7 @@ export default {
2422
@import "./../_vars.scss";
2523
2624
.pagebar {
27-
@include row($x: space-between, $y: center);
25+
@include row($x: space-between, $y: center, $wrap: nowrap);
2826
2927
margin-bottom: baseline();
3028
padding: baseline(0.5) 0;
@@ -33,6 +31,9 @@ export default {
3331
@include type(body);
3432
color: color(text-inverse);
3533
font-weight: bold;
34+
overflow: hidden;
35+
text-overflow: ellipsis;
36+
white-space: nowrap;
3637
3738
small {
3839
@include type(small);

src/pages/Agents.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
<btn inverse @click.prevent="create">Add an agent</btn>
55
</pagebar>
66

7-
<blankslate v-if="agents.length === 0" title="No agent yet!">
8-
Looks like you do not have any agent yet! Go ahead and create one!
9-
</blankslate>
10-
117
<list-item class="agents__list">
128
<card
139
v-for="agent in agents"
@@ -21,6 +17,10 @@
2117
</card>
2218
</list-item>
2319

20+
<blankslate v-if="agents.length === 0" title="No agent yet!">
21+
Looks like you do not have any agent yet! Go ahead and create one!
22+
</blankslate>
23+
2424
<form>
2525
<modal title="Create an agent" v-model="agentModal">
2626
<textinput label="Name" v-model="agent.name" />

src/pages/Entities.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
<btn inverse @click.prevent="create">Add an entity</btn>
55
</pagebar>
66

7-
<blankslate v-if="entities.length === 0" title="No entity yet!">
8-
Looks like you do not have any entity yet! Go ahead and create one!
9-
</blankslate>
10-
117
<list-item class="entities__list">
128
<card
139
@click.prevent="edit(entity)"
@@ -21,6 +17,10 @@
2117
</card>
2218
</list-item>
2319

20+
<blankslate v-if="entities.length === 0" title="No entity yet!">
21+
Looks like you do not have any entity yet! Go ahead and create one!
22+
</blankslate>
23+
2424
<form>
2525
<modal v-model="entityModal" :title="`${entity.id ? 'Update' : 'Create'} an entity`">
2626
<textinput label="Name" v-model="entity.name" />

src/pages/Skill.vue

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<template>
2+
<div class="skill">
3+
<pagebar :title="skill.name" :subtitle="skill.description">
4+
<btn inverse @click.prevent="edit">Edit skill</btn>
5+
</pagebar>
6+
7+
<form>
8+
<modal title="Edit skill" v-model="skillModal">
9+
<textinput label="Name" v-model="data.name" />
10+
<textinput label="Description" v-model="data.description" />
11+
12+
<btn slot="actions" danger @click.prevent="remove">Delete</btn>
13+
<btn submit slot="actions" @click.prevent="save">Save</btn>
14+
</modal>
15+
</form>
16+
</div>
17+
</template>
18+
19+
<script>
20+
import { actions } from './../store/agents';
21+
22+
import Modal from './../components/Modal.vue';
23+
import Textinput from './../components/Textinput.vue';
24+
import Btn from './../components/Btn.vue';
25+
import Pagebar from './../components/Pagebar.vue';
26+
27+
export default {
28+
name: 'Skill',
29+
components: { Pagebar, Btn, Modal, Textinput },
30+
data() {
31+
return {
32+
skillModal: false,
33+
data: {},
34+
};
35+
},
36+
computed: {
37+
skill() {
38+
return this.$store.getters.skill(this.$route.params.id);
39+
}
40+
},
41+
methods: {
42+
edit() {
43+
this.data = { ...this.skill };
44+
this.skillModal = true;
45+
},
46+
async remove() {
47+
await this.$store.dispatch(actions.removeSkill.name, this.data.id);
48+
this.$router.push({ name: 'skills' });
49+
},
50+
async save() {
51+
await this.$store.dispatch(actions.upsertSkill.name, this.data);
52+
this.skillModal = false;
53+
},
54+
},
55+
}
56+
</script>

src/pages/Skills.vue

+33-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@
44
<btn inverse @click.prevent="create">Add a skill</btn>
55
</pagebar>
66

7+
<list-item class="skills__list">
8+
<card
9+
v-for="skill in skills"
10+
:key="skill.id"
11+
class="skills__item"
12+
:to="{ name: 'skill', params: { id: skill.id } }"
13+
:title="skill.name"
14+
:subtitle="skill.description"
15+
>
16+
{{skill.intents.length}} intent{{skill.intents.length > 1 ? 's' : ''}}
17+
</card>
18+
</list-item>
19+
720
<blankslate v-if="skills.length === 0" title="No skill yet!">
821
Looks like you do not have any skill yet! Go ahead and create one!
922
</blankslate>
@@ -22,7 +35,10 @@
2235
<script>
2336
import { mapGetters } from 'vuex';
2437
38+
import ListItem from './../animations/ListItem.vue';
39+
2540
import Pagebar from './../components/Pagebar.vue';
41+
import Card from './../components/Card.vue';
2642
import Blankslate from './../components/Blankslate.vue';
2743
import Textinput from './../components/Textinput.vue';
2844
import Btn from './../components/Btn.vue';
@@ -31,7 +47,7 @@ import { actions } from './../store/agents';
3147
3248
export default {
3349
name: 'Skills',
34-
components: { Pagebar, Btn, Blankslate, Modal, Textinput },
50+
components: { Pagebar, Btn, Blankslate, Modal, Textinput, Card, ListItem },
3551
data() {
3652
return {
3753
skillModal: false,
@@ -60,5 +76,21 @@ export default {
6076
.skills {
6177
@include col($x: stretch, $y: flex-start);
6278
flex: 1;
79+
80+
&__list {
81+
@include row($gap: 27px);
82+
}
83+
84+
&__item {
85+
@include cell(1, $grow: 0);
86+
87+
@include on(tablet) {
88+
@include cell(1/3, $grow: 0);
89+
}
90+
91+
@include on(desktop) {
92+
@include cell(1/4, $grow: 0);
93+
}
94+
}
6395
}
6496
</style>

src/router/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Router from 'vue-router';
44
import Agents from './../pages/Agents.vue';
55
import Agent from './../pages/Agent.vue';
66
import Skills from './../pages/Skills.vue';
7+
import Skill from './../pages/Skill.vue';
78
import Entities from './../pages/Entities.vue';
89

910
Vue.use(Router);
@@ -31,6 +32,11 @@ export default function createRouter() {
3132
name: 'skills',
3233
component: Skills,
3334
},
35+
{
36+
path: '/skill/:id',
37+
name: 'skill',
38+
component: Skill,
39+
},
3440
],
3541
});
3642
}

src/store/agents.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ const mutations = {
6363
id,
6464
name,
6565
description,
66-
slots: {},
67-
data: [],
66+
intents: [],
6867
});
6968
},
70-
setSkill(state, { id }) {
69+
setSkill(state, { id, name, description }) {
7170
const skill = state.skills[id];
7271

7372
if (skill) {
74-
73+
skill.name = name;
74+
skill.description = description;
7575
}
7676
},
7777
deleteSkill(state, id) {
@@ -107,13 +107,17 @@ export const actions = {
107107
commit(mutations.addSkill.name, data);
108108
}
109109
},
110+
removeSkill({ commit }, id) {
111+
commit(mutations.deleteSkill.name, id);
112+
},
110113
};
111114

112115
const getters = {
113116
agents: state => Object.values(state.agents),
114117
skills: state => Object.values(state.skills),
115118
entities: state => Object.values(state.entities),
116119
agent: state => id => state.agents[id],
120+
skill: state => id => state.skills[id],
117121
};
118122

119123
const state = {

0 commit comments

Comments
 (0)