Skip to content

Commit 9282e76

Browse files
committed
Version 0.2.0
Merge branch 'dev'
2 parents de28a24 + 638fd29 commit 9282e76

16 files changed

+337
-166
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ticket-calc",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Simple ticket calculator",
55
"author": "Julien Tardot <[email protected]>",
66
"license": "MIT",

public/index.html

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
<meta name="theme-color" content="#e3001b">
1616

1717
<title>Ticket-Calc</title>
18+
19+
<meta name="description" content="Ticket-Calc allows you to determine the optimal number of tickets (restaurant tickets, vouchers) of different values you can use to pay for a given amount.">
20+
<meta name="keywords" content="Ticket-Calc, calculator, ticket restaurant, cheque dejeuner, voucher">
1821
</head>
1922
<body>
2023
<noscript>

public/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"type": "image/png"
1414
}
1515
],
16-
"start_url": "./index.html",
16+
"start_url": "/?utm_source=a2hs",
1717
"display": "standalone",
1818
"background_color": "#FFFFFF",
1919
"theme_color": "#E3001B"

src/App.vue

-5
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
<template>
2-
32
<div id="app" class="text-secondary text-xl">
43
<app-nav></app-nav>
54
<router-view/>
65
</div>
7-
86
</template>
97

108
<script>
11-
129
import AppNav from '@/components/Nav';
1310
1411
export default {
1512
components: {
1613
'app-nav': AppNav
1714
}
1815
}
19-
2016
</script>
2117

2218
<style>
23-
2419
</style>

src/assets/css/app.css

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
.f-row { @apply flex flex-row; }
66

77
hr {
8-
@apply border w-full my-6;
8+
@apply border w-full my-5;
99
}
1010

1111
/* Buttons */
@@ -45,7 +45,6 @@ hr {
4545
input {
4646
@apply border-2 rounded w-4/5 py-1 px-3;
4747
}
48-
4948
input, .input-value {
5049
@apply px-2;
5150
}

src/components/Nav.vue

-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
<template>
2-
32
<nav class="text-center font-semibold text-2xl p-6">
43
<router-link to="/">Calc</router-link>
54
|
65
<router-link to="/settings">Settings</router-link>
76
|
87
<router-link to="/about">About</router-link>
98
</nav>
10-
119
</template>
1210

1311
<style>
14-
1512
.router-link-exact-active {
1613
@apply text-primary;
1714
}
18-
1915
</style>

src/components/SolutionButtons.vue

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<template>
2+
<div>
3+
4+
<button class="solution-btn solution-btn-exact"
5+
v-for="(solution, index) in solutions['exact'].solutions" :key="'exact-' + index"
6+
@click="$emit('select', solution)">
7+
==
8+
</button>
9+
10+
<button class="solution-btn solution-btn-over"
11+
v-for="(solution, index) in solutions['over'].solutions" :key="'over-' + index"
12+
@click="$emit('select', solution)">
13+
&gt; {{ solutions['over'].diff | fixed2 }}
14+
</button>
15+
16+
<button class="solution-btn solution-btn-under"
17+
v-for="(solution, index) in solutions['under'].solutions" :key="'under-' + index"
18+
@click="$emit('select', solution)">
19+
&lt;
20+
{{ solutions['under'].diff | fixed2 }}
21+
</button>
22+
23+
</div>
24+
</template>
25+
26+
<script>
27+
export default {
28+
name: 'SolutionButtons',
29+
props: {
30+
solutions: {
31+
type: Object,
32+
required: true,
33+
}
34+
}
35+
}
36+
</script>
37+
38+
<style>
39+
.solution-btn {
40+
@apply py-1 px-3 rounded-full text-white font-bold;
41+
margin: .125rem;
42+
margin-top: 0;
43+
}
44+
.solution-btn:focus {
45+
@apply outline-none;
46+
}
47+
48+
.solution-btn.solution-btn-exact { @apply bg-equalBg; }
49+
.solution-btn.solution-btn-over { @apply bg-positiveBg; }
50+
.solution-btn.solution-btn-under { @apply bg-negativeBg; }
51+
</style>

src/components/TicketForm.vue

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<template>
2+
<div class="f-row flex-wrap my-3">
3+
4+
<div class="w-1/2 px-3">
5+
<label class="block text-s tracking-wide font-semibold mb-2"
6+
for="ticket-name">
7+
Name
8+
</label>
9+
<input class="block w-full border rounded "
10+
id="ticket-name" type="text" placeholder="Name"
11+
v-model.trim="ticket.name">
12+
</div>
13+
<div class="w-1/2 px-3">
14+
<label class="block text-s tracking-wide font-semibold mb-2"
15+
for="ticket-value">
16+
Value
17+
</label>
18+
<input class="block w-full border rounded "
19+
id="ticket-value" type="number" min="0" step="0.01" placeholder="Value"
20+
v-model.number="ticket.value">
21+
</div>
22+
23+
<div class="w-full text-center my-3">
24+
<button class="btn btn-primary-reverse border-2 border-primary" type="submit"
25+
@click="addTicketToStore"
26+
:disabled="!ticket.value">
27+
+ Add ticket
28+
</button>
29+
</div>
30+
31+
</div>
32+
</template>
33+
34+
<script>
35+
import {clone} from 'lodash';
36+
import {mapActions} from 'vuex'
37+
38+
import Ticket from "@/models/ticket";
39+
40+
export default {
41+
name: 'TicketForm',
42+
data() {
43+
return {
44+
ticket: new Ticket('', null)
45+
};
46+
},
47+
methods: {
48+
...mapActions([
49+
'addTicket',
50+
]),
51+
addTicketToStore() {
52+
this.addTicket(clone(this.ticket));
53+
this.resetNewTicket();
54+
},
55+
resetNewTicket() {
56+
this.ticket.name = '';
57+
this.ticket.value = null;
58+
},
59+
}
60+
}
61+
</script>
62+
63+
<style>
64+
</style>

src/components/TicketQuantityRow.vue

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<template>
2+
<div class="f-row my-2">
3+
4+
<span class="col-start f-row">
5+
<span class="flex-grow"> {{ ticketQuantity.ticket.name }} </span>
6+
<span class="mx-3"> @ </span>
7+
<span class="flex-grow"> {{ ticketQuantity.ticket.value | fixed2 }}</span>
8+
</span>
9+
10+
<div class="col-end">
11+
<button class="btn-square btn-primary align-middle text-xl"
12+
:disabled="buttonsDisabled"
13+
@click="ticketQuantity.sub()">
14+
-
15+
</button>
16+
<span class="input-value inline-block align-middle mx-2 w-12">
17+
{{ ticketQuantity.quantity }}
18+
</span>
19+
<button class="btn-square btn-primary align-middle text-xl"
20+
:disabled="buttonsDisabled"
21+
@click="ticketQuantity.add()">
22+
+
23+
</button>
24+
</div>
25+
26+
</div>
27+
</template>
28+
29+
<script>
30+
import TicketQuantity from "@/models/ticket-quantity";
31+
32+
export default {
33+
name: 'TicketQuantityRow',
34+
props: {
35+
buttonsDisabled: {
36+
type: Boolean,
37+
default: true,
38+
},
39+
ticketQuantity: {
40+
type: TicketQuantity,
41+
required: true,
42+
}
43+
}
44+
}
45+
</script>
46+
47+
<style>
48+
</style>

src/components/TicketRow.vue

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<template>
2+
<div class="f-row px-3 pb-3 mt-3 border-b last-child:border-b-0">
3+
4+
<span class="w-1/2">{{ ticket.name }}</span>
5+
<span class="mx-2"> @ </span>
6+
<span class="flex-grow">{{ ticket.value | fixed2 }}</span>
7+
8+
<button class="btn-round btn-primary" @click="dropTicketFromStore(index)"> x </button>
9+
10+
</div>
11+
</template>
12+
13+
<script>
14+
import {mapActions} from 'vuex'
15+
16+
import Ticket from "@/models/ticket";
17+
18+
export default {
19+
name: 'TicketRow',
20+
props: {
21+
index: {
22+
type: Number,
23+
required: true,
24+
},
25+
ticket: {
26+
type: Ticket,
27+
required: true,
28+
}
29+
},
30+
methods: {
31+
...mapActions([
32+
'dropTicket',
33+
]),
34+
dropTicketFromStore(index) {
35+
this.dropTicket(index);
36+
}
37+
}
38+
}
39+
</script>
40+
41+
<style>
42+
</style>

src/models/ticket.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,25 @@
22
export default class Ticket {
33

44
name = '';
5-
value = 0;
5+
value = null;
66

77
/**
88
* @param {string} name
9-
* @param {number} value
9+
* @param {number|null} value
1010
*/
11-
constructor(name, value) {
11+
constructor(name, value = null) {
1212
this.name = name;
1313
this.value = value;
1414
}
1515

16+
/**
17+
* @param {{name: string, value: number}} data
18+
* @returns {Ticket}
19+
*/
20+
static fromObject(data) {
21+
return new Ticket(data.name, data.value);
22+
}
23+
1624
/**
1725
* @returns {string}
1826
*/

src/store.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Vue from 'vue';
22
import Vuex from 'vuex';
33

4+
import Ticket from "@/models/ticket";
45
import Storage from "@/services/storage";
56

67
Vue.use(Vuex);
@@ -13,7 +14,7 @@ export default new Vuex.Store({
1314
new Storage('ticket-calc').plugin
1415
],
1516
getters: {
16-
tickets: state => state.tickets,
17+
tickets: state => state.tickets.map(Ticket.fromObject),
1718
},
1819
mutations: {
1920
addTicket(state, ticket) {

0 commit comments

Comments
 (0)