- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
- 219
- 220
- 221
- 222
- 223
- 224
- 225
- 226
- 227
- 228
- 229
- 230
- 231
- 232
- 233
- 234
- 235
- 236
- 237
- 238
- 239
- 240
- 241
- 242
- 243
- 244
- 245
- 246
- 247
- 248
- 249
- 250
- 251
- 252
- 253
- 254
- 255
- 256
- 257
- 258
- 259
- 260
- 261
- 262
- 263
- 264
- 265
- 266
- 267
- 268
- 269
- 270
- 271
- 272
- 273
- 274
- 275
- 276
- 277
- 278
- 279
- 280
- 281
- 282
- 283
- 284
- 285
- 286
- 287
- 288
- 289
- 290
- 291
- 292
- 293
- 294
- 295
- 296
- 297
- 298
- 299
- 300
- 301
- 302
- 303
- 304
- 305
- 306
- 307
- 308
- 309
- 310
- 311
- 312
<template>
<main>
<h2 class="ui header">Create & schedule a flip</h2>
<form class="ui large form" @submit.prevent='handleSubmit'>
<!-- BASIC INFO -->
<div class="ui attached message">
<h3 class="ui header">Basic info</h3>
</div>
<div class="ui attached segment">
<div class="three fields">
<div class="required field">
<label>Flip Name</label>
<i>Just a name so you can edit this later if needed</i>
<input type="text" name="flip-name" placeholder="Cybermonday 2017">
</div>
<div class=" required field">
<label>Sitewide promoset</label>
<i>Will apply to catalog pages</i>
<select class="ui search selection dropdown" data-dropdown-promos>
<option value="">select a promo</option>
</select>
</div>
<div class="required field">
<label>Flip Date</label>
<i>Date & time for this flip</i>
<div class="ui calendar">
<div class="ui left icon input">
<i class="calendar icon"></i>
<input type="text" name="flip-date" placeholder="4th of July 2017">
</div>
</div>
</div>
</div>
</div>
<!-- LANDING PAGES -->
<div class="ui attached message">
<h3 class="ui header">Landing Pages</h3>
</div>
<div class="ui attached segment" :class="{'loading': !constants}">
<p>
Below are our <b>"constant"</b> landing pages. Specify which page they will "mirror" next flip.
</p>
<div class="four fields">
<div class="field" v-for='(page, index) in constants'>
<label>{{ page }}</label>
<select class="ui search selection dropdown" data-dropdown-pages data-page='sitewide'>
<option value="">select a page</option>
</select>
</div>
<div class="four fields">
<!-- <div class="field">
<label>curso</label>
<select class="ui search selection dropdown" data-dropdown-pages data-page='curso'>
<option value="">select a page</option>
</select>
</div>
<div class="field">
<label>aprende</label>
<select class="ui search selection dropdown" data-dropdown-pages data-page='aprende'>
<option value="">select a page</option>
</select>
</div> -->
</div>
</div>
<!-- ASSETS -->
<div class="ui attached message">
<h3 class="ui header">Sitewide Images & Criteo</h3>
</div>
<div class="ui attached segment ">
<p>Select assets to upload. You can select more than one.</p>
<div class="field">
<input type="file" multiple>
</div>
</div>
<div class="ui bottom attached tiny info message" style="display:none">
<i class="warning icon"></i><b>Typically used assets are</b>:
<div>
<div class="ui horizontal list">
<div class="item">mdot-rto.jpg</div>
<div class="item">us-buynow.jpg</div>
<div class="item">us-freedemo.jpg</div>
<div class="item">us-freedemo-mobile.jpg</div>
</div>
<div class="ui horizontal list">
<div class="item">us-hslpbanner.jpg</div>
<div class="item">es-buynow.jpg</div>
<div class="item">es-homepage-bg.png</div>
<div class="item">es-catalog.jpg</div>
</div>
</div>
</div>
<!-- MDOT RTO -->
<div class="ui segment">
<div class="two fields" style="align-items: center">
<div class="four wide field">
<div class="ui toggle checkbox">
<input type="checkbox" name="mobile-rto" tabindex="0" class="hidden" @change='handleRtoToggle'>
<label>Show m. RTO?</label>
</div>
</div>
<div class="fourteen wide field" style="opacity: 0">
<input type="text" name="mobile-rto-url" placeholder="RTO url">
</div>
</div>
<div class="two fields" style="align-items: center">
<div class="four wide field">
<div class="ui toggle checkbox">
<input type="checkbox" name="homepage-rto" tabindex="0" class="hidden" @:change='handleRtoToggle'>
<label>Show home page RTO?</label>
</div>
</div>
<div class="fourteen wide field" style="opacity: 0">
<input type="text" name="homepage-rto-url" placeholder="RTO url">
</div>
</div>
</div>
<input type="submit" class="ui fluid primary big button" value="create & schedule" />
</form>
</main>
</template>
<script>
export default {
name: 'CreateFlip',
components: { },
data() {
return {
constants: 0,
temppages: 0
}
},
mounted() {
this.$http.get(`${window.server}/get-page-names`).then(res => {
var pages = JSON.parse(res.body)
// Constant pages
this.constants = Object.keys(pages).map(page => {
if (pages[page].metadata.constant) return page
}).filter(page => page !== undefined)
// Temp pages ( campaign based )
this.temppages = Object.keys(pages).map(page => {
if (!pages[page].metadata.constant) return page
}).filter(page => page !== undefined)
console.log(this.temppages)
}, err => {
})
/* Initialize pages search fields */
// TODO http://semantic-ui.com/introduction/new.html#translates-any-api
// TODO filter out constant pages so you cant map sitewide to sitewide, etc
// window.$('[data-dropdown-pages]').dropdown({
// //match: 'text',
// //showOnFocus: false,
// apiSettings: {
// url: `${window.server}/get-page-names?ui=true&filter=constant`,
// saveRemoteData: true
// }
// })
// window.$('[data-dropdown-promos]').dropdown({
// apiSettings: {
// url: `${window.server}/get-promo-names?ui=true`,
// saveRemoteData: true
// }
// })
/* Initialize calendar field */
//$('.ui.calendar').calendar()
//$('.ui.toggle.checkbox').checkbox()
},
methods: {
/*
* When we toggle an RTO checkbox, we show/hide
* the url input to its right
*/
handleRtoToggle(e) {
const isChecked = $(e.target).parent().hasClass('checked')
$(e.target).parents('.wide.field').siblings('.wide.field').animate({
opacity: isChecked
})
},
handleSubmit() {
const
name = document.querySelector('input[name=flip-name]').value
, promoset = document.querySelector('input[name=flip-name]').value
, date = document.querySelector('input[name=flip-date]').value
, sitewide = document.querySelector('select[data-page=sitewide]').value
, rmsitewide = document.querySelector('select[data-page=rmsitewide]').value
, sale = document.querySelector('select[data-page=sale]').value
, social = document.querySelector('select[data-page=social]').value
, curso = document.querySelector('select[data-page=curso]').value
, aprende = document.querySelector('select[data-page=aprende]').value
, assets = [...document.querySelector('input[type=file]').files]
, mRto = $('input[name=mobile-rto]').parent().hasClass('checked')
, mRtoUrl = $('input[name=mobile-rto-url').val()
, hRto = $('input[name=homepage-rto]').parent().hasClass('checked')
, hRtoUrl = $('input[name=homepage-rto-url').val()
;
const formdata = new FormData()
formdata.append('name', name)
formdata.append('promoset', promoset)
formdata.append('date', date)
formdata.append('sitewide', sitewide)
formdata.append('rmsitewide', rmsitewide)
formdata.append('sale', sale)
formdata.append('social', social)
formdata.append('curso', curso)
formdata.append('aprende', aprende)
formdata.append('mobile-rto', mRto)
formdata.append('mobile-rto-url', mRtoUrl)
formdata.append('homepage-rto', hRto)
formdata.append('homepage-rto-url', hRtoUrl)
assets.forEach(ass => formdata.append('assets[]', ass, ass.name))
const req = $.ajax({
method: 'post',
url: window.server + '/create-flip',
contentType: false,
processData: false,
data: formdata
})
req.done(r => {
})
}
},
vuex: {
actions: {
// Key 'toggle' here just has to match
// the @click fn name in the template above.
// No need for methods { } functions
//toggle: toggleAddModal
}
}
}
$(() => {
window.setTimeout(function() {
console.log(typeof jQuery.dropdown)
}, 3000)
})
</script>