Skip to content

Commit 225f9ce

Browse files
authored
Merge pull request #1 from tutorcruncher/enquiry-form
Enquiry form
2 parents d0fee05 + 7e96e07 commit 225f9ce

File tree

14 files changed

+563
-161
lines changed

14 files changed

+563
-161
lines changed

config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module.exports = {
4646
// SOCKET_API_URL: '"api/"',
4747
SOCKET_API_URL: '"https://socket.tutorcruncher.com"',
4848
},
49-
port: 8000,
49+
port: 5000,
5050
build_dir: path.resolve(__dirname, 'dev'),
5151
css_source_map: true,
5252
public_path: '/',

src/components/con-details.vue

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
11
<template>
22
<div>
3-
<div class="tcs-location">
4-
<!--
5-
this is the svg for map icon straight from
6-
https://github.com/encharm/Font-Awesome-SVG-PNG/blob/master/black/svg/map-marker.svg
7-
-->
8-
<svg class="tcs-svg" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg">
9-
<path d="M1152 640q0-106-75-181t-181-75-181 75-75 181 75 181 181 75 181-75 75-181zm256 0q0 109-33
10-
179l-364 774q-16 33-47.5 52t-67.5 19-67.5-19-46.5-52l-365-774q-33-70-33-179 0-212 150-362t362-150
11-
362 150 150 362z"/>
12-
</svg>
13-
<span>{{ contractor.town }}, {{ contractor.country }}</span>
14-
</div>
15-
16-
<div class="tcs-aside tcs-md" v-html="to_markdown(contractor.tag_line)"></div>
17-
183
<div class="tcs-md" v-html="to_markdown(contractor.primary_description)"></div>
194

205
<div class="tcs-attr" v-for="attr in contractor_extra.extra_attributes">
@@ -59,45 +44,19 @@ export default {
5944
contractor_extra: function () {
6045
return this.$root.contractors_extra[this.$route.params.link] || {}
6146
},
62-
},
63-
created: function () {
64-
// TODO could do something less ugly here like hide the scroll bar at all times
65-
this.body_overflow_before = document.body.style.overflow
66-
document.body.style.overflow = 'hidden'
67-
},
68-
destroyed: function () {
69-
document.body.style.overflow = this.body_overflow_before
7047
}
7148
}
7249
</script>
7350

7451
<style lang="scss">
7552
@import '../conf';
7653
77-
.tcs-location {
78-
margin-bottom: 10px;
79-
float: right;
80-
span {
81-
display: inline-block;
82-
padding-top: 4px;
83-
vertical-align: top;
84-
font-weight: 500;
85-
}
86-
}
87-
8854
.tcs-md {
8955
p {
9056
margin: 0 0 8px;
9157
}
9258
}
9359
94-
.tcs-aside {
95-
font-size: 22px;
96-
margin-bottom: 10px;
97-
color: $hightlight;
98-
min-height: 28px;
99-
}
100-
10160
h3 {
10261
margin-top: 12px;
10362
margin-bottom: 4px;

src/components/enquiry.vue

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<template>
2+
<div>
3+
<div class="tcs-submitted" v-if="submitted" v-html="$root.get_text('enquiry_submitted_thanks', {}, true)"></div>
4+
<div v-else>
5+
<p class="tcs">
6+
{{ $root.get_text('contractor_enquiry_message', {contractor_name: contractor.name}) }}
7+
</p>
8+
<form class="tcs" @submit.prevent="submit">
9+
<div v-for="field in visible_fields">
10+
<input_ :field="field"></input_>
11+
</div>
12+
<div v-for="field in attribute_fields">
13+
<input_ :field="field" prefix="attributes"></input_>
14+
</div>
15+
<div class="tcs-field tcs-submit">
16+
<button type="submit">
17+
{{ $root.config.submit_enquiry }}
18+
</button>
19+
</div>
20+
</form>
21+
</div>
22+
</div>
23+
</template>
24+
25+
<script>
26+
var input = require('./input')
27+
28+
export default {
29+
name: 'enquiry',
30+
props: ['contractor'],
31+
components: {
32+
'input_': input
33+
},
34+
computed: {
35+
visible_fields: function () {
36+
return this.$root.enquiry_form_info.visible || []
37+
},
38+
attribute_fields: function () {
39+
return this.$root.enquiry_form_info.attributes || []
40+
}
41+
},
42+
data: () => ({
43+
submitted: false
44+
}),
45+
methods: {
46+
submit: function () {
47+
this.$set(this.$root.enquiry_data, 'contractor', this.contractor.id)
48+
this.$root.submit_enquiry(this.submission_complete)
49+
},
50+
submission_complete: function () {
51+
this.submitted = true
52+
}
53+
},
54+
}
55+
</script>
56+
57+
<style lang="scss">
58+
@import '../conf';
59+
60+
form.tcs {
61+
margin: auto;
62+
max-width: 450px;
63+
}
64+
65+
p.tcs {
66+
margin: 0 0 10px;
67+
}
68+
69+
.tcs-submitted {
70+
text-align: center;
71+
font-size: 20px;
72+
padding: 30px 40px;
73+
}
74+
75+
.tcs-submit {
76+
text-align: right;
77+
button {
78+
font-size: 17px;
79+
padding: 6px 12px;
80+
border: none;
81+
border-radius: 4px;
82+
83+
background-color: $button-colour;
84+
color: white;
85+
transition: all .3s ease;
86+
outline: none;
87+
cursor: pointer;
88+
&:hover {
89+
background-color: darken($button-colour, 20%);
90+
}
91+
}
92+
}
93+
</style>

src/components/input.vue

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<template>
2+
<div class="tcs-field">
3+
<textarea v-if="is_textarea"
4+
:name="name"
5+
:placeholder="field.label"
6+
:required="field.required"
7+
:maxlength="field.max_length || 255"
8+
:value="value"
9+
@input="changed"
10+
rows="5">
11+
</textarea>
12+
<input v-else
13+
:type="field.type"
14+
:name="name"
15+
:placeholder="field.label"
16+
:required="field.required"
17+
:maxlength="field.max_length || 255"
18+
:value="value"
19+
@input="changed">
20+
</div>
21+
</template>
22+
23+
<script>
24+
export default {
25+
name: 'input',
26+
props: {
27+
field: Object,
28+
prefix: {
29+
type: String,
30+
default: ''
31+
},
32+
},
33+
computed: {
34+
is_textarea: function () {
35+
// TODO return this.field.type === 'text' && this.field.max_length > 500
36+
return this.field.type === 'text' && this.prefix === 'attributes'
37+
},
38+
name: function () {
39+
return this.prefix + '.' + this.field.field
40+
},
41+
value: function () {
42+
if (this.prefix === '') {
43+
return this.$root.enquiry_data[this.field.field] || ''
44+
} else {
45+
return (this.$root.enquiry_data[this.prefix] || {})[this.field.field] || ''
46+
}
47+
}
48+
},
49+
methods: {
50+
changed: function (event) {
51+
if (this.prefix === '') {
52+
this.$set(this.$root.enquiry_data, this.field.field, event.target.value)
53+
} else {
54+
var obj = this.$root.enquiry_data[this.prefix] || {}
55+
obj[this.field.field] = event.target.value
56+
this.$set(this.$root.enquiry_data, this.prefix, obj)
57+
}
58+
}
59+
},
60+
}
61+
</script>
62+
63+
<style lang="scss">
64+
@import '../conf';
65+
66+
$border-colour: #66afe9;
67+
.tcs-field {
68+
padding: 8px 0;
69+
width: 100%;
70+
input, textarea {
71+
font-size: 16px;
72+
width: calc(100% - 26px);
73+
padding: 10px 12px;
74+
border-radius: 5px;
75+
border: 1px solid #aaa;
76+
font-family: inherit;
77+
outline: none;
78+
&:focus {
79+
border-color: $border-colour;
80+
box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px lighten($border-colour, 20%);
81+
}
82+
}
83+
}
84+
</style>

0 commit comments

Comments
 (0)