Date Fields improvements

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
DevGiu
AppGini Super Hero
AppGini Super Hero
Posts: 151
Joined: 2016-05-27 09:08

Date Fields improvements

Post by DevGiu » 2016-07-11 18:34

I noticed 2 annoying thngs with date Fields.

First, it allows you to put an invalid date (fr example, 30 February) and then nothing is saved . If date is invalid shouldn't validate the form.

Second, could be interesting to have date Fields in the form of a simple edit to write 11/07/2016 with the calendar option to choose a date.

Maybe I'm missing something, I have 1hour total in front of appgini since I bought, busy ,sadly, with non appgini projects
/Giuseppe
Professional Outsourcing Services

DevGiu
AppGini Super Hero
AppGini Super Hero
Posts: 151
Joined: 2016-05-27 09:08

Re: Date Fields improvements

Post by DevGiu » 2016-07-15 19:08

Seems like @grimblefritz is the only forumer walking here :)
/Giuseppe
Professional Outsourcing Services

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: Date Fields improvements

Post by grimblefritz » 2016-07-15 22:32

Between jobs and bored, and I've owned AG for several years - finally time to do something with it :)

Aya Adel
Posts: 7
Joined: 2016-08-08 07:29

Re: Date Fields improvements

Post by Aya Adel » 2016-08-10 21:23

DevGiu wrote:I noticed 2 annoying thngs with date Fields.

First, it allows you to put an invalid date (fr example, 30 February) and then nothing is saved . If date is invalid shouldn't validate the form.

Second, could be interesting to have date Fields in the form of a simple edit to write 11/07/2016 with the calendar option to choose a date.

Maybe I'm missing something, I have 1hour total in front of appgini since I bought, busy ,sadly, with non appgini projects

I guess what you're looking for is already supported in AppGini. Kindly check the attached screenshots
Attachments
2016-08-10_2319.png
2016-08-10_2319.png (58.76 KiB) Viewed 14364 times
2016-08-10_2315.png
2016-08-10_2315.png (60.64 KiB) Viewed 14364 times

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: Date Fields improvements

Post by grimblefritz » 2016-08-10 22:00

No, he wasn't referring to the date picker.

If you use the drop downs for Order Date, you can enter February 31, 2016. That's obviously incorrect. Furthermore, rather than interpreting the date as March 2, as some other date entry systems do, it will (if you subsequently click the date picker) show Feb 29 as being selected - but if you save the record, it will result in a null field as sql will see 2016-02-31 as invalid.

His second request is for a mode, as many date entry systems provide, where you get a masked input area with "__/__/____" where you can simply key in the date. Personally, I'd rather have that plus the date picker, rather than the three dropdowns and the date picker.

DevGiu
AppGini Super Hero
AppGini Super Hero
Posts: 151
Joined: 2016-05-27 09:08

Re: Date Fields improvements

Post by DevGiu » 2016-08-11 09:38

As grimblefritz explains, the problem is not the calendar is not ok in calendar popuyp. The problem is date is not checked when selected from dropdowns, so it allows to set 30 Feb 2015 for example. 30 Feb is not a valid date, but there are any warning, and when save, this date is not saved on database (because database rejects because is not a valid date) and writes NULL instead. AppGini should add in his core validation for save, for date fields, to check if it's a valid or not.

About second, again, as grimblefritz explains, could be interesting for date fields an option in AppGini to choose how you want to represent date fields.
One way is as now, 3 combos to choose day, month and year. This is cool for tablet/phone but sometimes you may need a simple input to write a date directly with keyboard, and with the ability to select it /change it from a calendar widget.
/Giuseppe
Professional Outsourcing Services

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: Date Fields improvements

Post by grimblefritz » 2016-08-11 13:10

Using @media to detect screen width would be one option. On small (<768px) screens, use the current solution. For wider screens, add a masked text field for keyboard entry.

This thread should be moved to feature requests...

DevGiu
AppGini Super Hero
AppGini Super Hero
Posts: 151
Joined: 2016-05-27 09:08

Re: Date Fields improvements

Post by DevGiu » 2016-08-11 20:31

grimblefritz wrote:Using @media to detect screen width would be one option. On small (<768px) screens, use the current solution. For wider screens, add a masked text field for keyboard entry.

This thread should be moved to feature requests...
Agree. This is the best way to go
/Giuseppe
Professional Outsourcing Services

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: Date Fields improvements

Post by grimblefritz » 2016-08-30 17:09


peebee
AppGini Super Hero
AppGini Super Hero
Posts: 352
Joined: 2013-03-21 04:37

Re: Date Fields improvements

Post by peebee » 2016-08-31 03:10

OK, following on from grimblefritz's Masked Input contribution here: http://forums.appgini.com/phpbb/viewtop ... f=6&p=6352

I just installed this: https://github.com/RobinHerbots/jquery.inputmask Had a quick play around and found it to be fantastic!

Apart from multiple masks I've added for currency, decimals and an assortment of other bits and pieces, I also had a play around with some date fields I use.

Outcome: Date field with jQuery Datepicker + correctly formatted date (dd/mm/yyyy in my case) + ability to type directly (into just a simple text field - not an AppGini date dropdown field) using jQuery UI

How to:
To make my life a little easier, I chose to use the supplied bundled inputmask.bundle.js I also chose to use Google's hosted jQuery UI

Upload jquery.inputmask.bundle.js to your hooks folder then simply add this to hooks/footer-extras.php (calls the inputmask.js & Google's hosted jQuery UI)

Code: Select all

<script src="hooks/jquery.inputmask.bundle.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
Then add this to tablename-dv.js

Code: Select all

(function($) {
$(document).ready(function(){
  $('#yourdatefield').datepicker({
  dateFormat: 'dd/mm/yy',
  changeMonth: true,
  changeYear: true
}).inputmask('dd/mm/yyyy');
});
})(jQuery);
Nice neat (mobile friendly) output:
screenshot1.jpg
screenshot1.jpg (115.29 KiB) Viewed 14311 times

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: Date Fields improvements

Post by grimblefritz » 2016-08-31 12:25

That looks very promising! I'm hoping Ahmad will find a way to nicely integrate this into AppGini. Meanwhile... this is what hooks are for :)

DevGiu
AppGini Super Hero
AppGini Super Hero
Posts: 151
Joined: 2016-05-27 09:08

Re: Date Fields improvements

Post by DevGiu » 2016-09-25 17:40

@peebee I'm right if I think you changed your field to varchar? I can't get it working as Date, changing to varchar, then worked.
/Giuseppe
Professional Outsourcing Services

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 352
Joined: 2013-03-21 04:37

Re: Date Fields improvements

Post by peebee » 2016-09-25 23:32

Apologies, yes I should have added that the field should be varchar rather than a date field. Input mask validates as correct date format so no risk of incorrect data entry.

DevGiu
AppGini Super Hero
AppGini Super Hero
Posts: 151
Joined: 2016-05-27 09:08

Re: Date Fields improvements

Post by DevGiu » 2016-09-26 07:49

peebee wrote:Apologies, yes I should have added that the field should be varchar rather than a date field. Input mask validates as correct date format so no risk of incorrect data entry.
Uhm..I have to think about this. I don't like too much to change my field datatype just because the inputmask.
/Giuseppe
Professional Outsourcing Services

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: Date Fields improvements

Post by grimblefritz » 2016-09-26 12:20

Could you not leave the field datatype alone, and use jquery to modify the input field on the form?

DevGiu
AppGini Super Hero
AppGini Super Hero
Posts: 151
Joined: 2016-05-27 09:08

Re: Date Fields improvements

Post by DevGiu » 2016-09-26 12:27

Date fields are splited in 3
/Giuseppe
Professional Outsourcing Services

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: Date Fields improvements

Post by grimblefritz » 2016-09-26 12:43

Yes, but you could hide them, accept input into a new input field (you create - see my mkfield lib), and then parse the input into the three hidden fields.

DevGiu
AppGini Super Hero
AppGini Super Hero
Posts: 151
Joined: 2016-05-27 09:08

Re: Date Fields improvements

Post by DevGiu » 2016-09-26 12:48

Uhm...you have some sample for this done?
/Giuseppe
Professional Outsourcing Services

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: Date Fields improvements

Post by grimblefritz » 2016-09-26 13:24

Nope, just speculating as to how I would address it.

Post Reply