Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes: U4-9273 Add date picker to query builder #1648

Merged
merged 9 commits into from Jan 4, 2017

Conversation

madsrasmussen
Copy link
Contributor

No description provided.

Copy link
Contributor

@warrenbuckley warrenbuckley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code seems OK, just a couple questions I have if you don't mind answering @madsrasmussen for clarity please.

pickDate: true,
pickTime: true,
useSeconds: true,
format: "YYYY-MM-DD HH:mm:ss",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@madsrasmussen with this being a date and a time picker we may need to add a new property for timezones.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this example in the docs does it show all possible options/config values that can be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should just modify the dates inside the directive? I can see it uses moments for something but haven't really spend time on it.

The docs doesn't show all the config options but I have added a link to the original documentation.


function onInit() {
// load css file for the date picker
assetsService.loadCss('lib/datetimepicker/bootstrap-datetimepicker.min.css').then(function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any need for the then() as we are not doing anything with the promise once the CSS loaded/resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is now removed :)

if (scope.onChange && event.date && event.date.isValid()) {
scope.$apply(function(){
// Update ngModel
scope.ngModel = event.date.format(scope.options.format);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the format used for display purposes or is the format used when being sent back to the server endpoints, as to make life easier with datetimes, formats & timezone hell, I think it may need to be consistently sent to the server in a format that is agreed upon, as if you were to change it clientside the server side may interpret the date as the totally wrong month.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed this code a bit because of some timing issues. You now have to use the raw date from one of the callbacks and can do whatever is needed with that. I hope it makes sense 👍

element
.datetimepicker(angular.extend({ useCurrent: true }, scope.options))
.on("dp.change", onChange)
.on("dp.error", onError);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the underlying library that is being used have any other useful events that are being fired that might be useful for anyone else using this component & worth adding?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added the rest of the events from the documentation also: http://eonasdan.github.io/bootstrap-datetimepicker/Events/



function datePickerChange(event) {
templateQueryResource.postTemplateQuery(vm.query)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I am wrong @madsrasmussen but the main directive model is filter.constraintValue and I was expecting this function to update vm.query to include the chosen date to post to the server for the query to be made.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value was updated on ngModel but there were some timing issues which f***** it up. I have changed the code a bit so you now have to use the date which comes from the callback. If I understand you correctly, the code is now what you expected to see and not so much angular magic :)

@@ -0,0 +1,143 @@
/**
@ngdoc directive
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps with the doc comment, indicate what version it will be for. In case package devs try to use it in an older version of Umbraco.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is now added to the docs 👍

@bjarnef
Copy link
Contributor

bjarnef commented Dec 14, 2016

@madsrasmussen maybe there are some stuff in my previously PR here you can re-use? #984

@madsrasmussen
Copy link
Contributor Author

@bjarnef As far as I understand your PR, it is for exposing all the different config options in a UI. What I am doing here is wrapping the load, init and events of the date picker in a directive so the code is a bit cleaner and easier to reuse. But thanks for your input 👍 I hope there will be time to go through all the waiting PR's soon and then we make everything work together.

@bjarnef
Copy link
Contributor

bjarnef commented Dec 21, 2016

@madsrasmussen yes, I just noticed the config where it set pickDate, pickTime and useSeconds to true

pickDate: true,
pickTime: true,
useSeconds: true,
format: "YYYY-MM-DD HH:mm:ss",

in my PR I changed these config option based on the format property, so I only had 1 config option instead of 4. But not sure if it should be possible to use this Angular directive as a "time picker" too?

Copy link
Contributor

@warrenbuckley warrenbuckley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few minor things @madsrasmussen

}

function onUpdate(event) {
if (scope.onShow) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct @madsrasmussen I would have thought it should check if we have a function set in scope.onUpdate which we then run it

}

function onHide(event) {
if (scope.onChange) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct @madsrasmussen I would have thought it should check if we have a function set in scope.onHide which we then run it

@@ -1,14 +1,20 @@
(function () {
"use strict";

function QueryBuilderOverlayController($scope, templateQueryResource) {
function QueryBuilderOverlayController($scope, $element, templateQueryResource, assetsService, angularHelper) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The three extra injected dependencies don't seem to be used in this file so best to be neat & tidy and remove them please @madsrasmussen

@madsrasmussen
Copy link
Contributor Author

@warrenbuckley good catches. They are fixed now 👍

@warrenbuckley
Copy link
Contributor

Thanks for the speedy changes - currently testing creating a property editor using this directive to ensure things are wired up.

@warrenbuckley
Copy link
Contributor

OK after reading the wrong/old docs from an earlier commit & wondering why I could not get ng-model to work for the directive in my prop editor test. Only to realise doc was out of date I was reading & that Mads has given an example using the change event fired by the underling date picker JS library.

All tested & code sanity checked. All happy & merging in.

@warrenbuckley warrenbuckley merged commit 1a215f3 into temp-template-editor Jan 4, 2017
@warrenbuckley warrenbuckley deleted the temp-U4-9273 branch January 4, 2017 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants