Skip to content

Instantly share code, notes, and snippets.

@kasperkamperman
Created October 28, 2020 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kasperkamperman/8bdff5b3beee002ae733aae066f27629 to your computer and use it in GitHub Desktop.
Save kasperkamperman/8bdff5b3beee002ae733aae066f27629 to your computer and use it in GitHub Desktop.
whole code for bug.
App.Utils.renderer['date-range'] = function(v) {
console.log(v);
/*
if (!v.from || !v.from.date) return '';
if (v.from.date && !v.to.date || v.from.date == v.to.date) {
if (v.from.time && v.to.time)
return v.from.date + ' (' + v.from.time + ' - ' + v.to.time + ')';
else if (v.from.time)
return v.from.date + ' (' + v.from.time + ')';
else if (v.to.time)
return v.from.date + ' (' + v.to.time + ')';
else return v.from.date
}
return v.from.date + (v.from.time ? ' (' + v.from.time + ')' : '') + (v.to.date ? ' - ' + v.to.date : '') + (v.to.time ? ' (' + v.to.time + ')' : '');
*/
};
<field-openinghours>
<style>
.uk-autocomplete
,label
{
display:block;
}
</style>
<div class="uk-grid uk-grid-match uk-grid-gutter">
<div class="uk-width-medium-1-1 uk-grid uk-grid-match">
<div class="uk-width-medium-1-1 uk-margin-small">
<div class="uk-width-medium-1-6">
<label><i class="uk-icon-calendar"></i> <span class="uk-text-bold">{ App.i18n.get('Date') }</span></label>
</div>
<div class="uk-width-medium-1-6">
<label><span class="uk-text-bold">{ App.i18n.get('Start') }</span></label>
<field-date bind="value.from.date"></field-date>
</div>
<div class="uk-width-medium-1-6">
<label><span class="uk-text-bold">{ App.i18n.get('End') }</span></label>
<field-date bind="value.to.date"></field-date>
</div>
</div>
</div>
<div class="uk-width-medium-1-1 uk-grid uk-grid-match">
<div class="uk-width-medium-1-6">
<label><i class="uk-icon-clock-o"></i> <span class="uk-text-bold">{ App.i18n.get('Monday') }</span></label>
</div>
<div class="uk-width-medium-1-6">
<label><span class="uk-text-bold">{ App.i18n.get('From') }</span></label>
<field-time bind="value.from.time"></field-time>
</div>
<div class="uk-width-medium-1-6">
<label><span class="uk-text-bold">{ App.i18n.get('To') }</span></label>
<field-time bind="value.to.time"></field-time>
</div>
<div class="uk-width-medium-1-6">
<label><span class="uk-text-bold">{ App.i18n.get('Closed all day') }</span></label>
<div>
<input type="checkbox">
</div>
</div>
</div>
<div class="uk-width-medium-1-1 uk-grid uk-grid-match">
<field-object opts="{ test }"></field-object>
<field-object opts="{ 'height':'600px' }"></field-object>
</div>
</div>
<script>
var $this = this;
this.test = {
"height": "600px"
}
this.value = {};
riot.util.bind(this);
this.$updateValue = function(value, field) {
if (!App.Utils.isObject(value) || Array.isArray(value)) {
value = {"from":{"date":null,"time":null},"to":{"date":null,"time":null}};
}
if (JSON.stringify(this.value) != JSON.stringify(value)) {
this.value = value;
this.update();
}
}.bind(this);
this.on('bindingupdated', function() {
$this.$setValue(this.value);
});
</script>
</field-openinghours>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment