This issue is about changing all of PM's date fields from using a custom field (broken in Drupal 7) to use the Drupal Field API.

The date project is one of the most installed in Drupal, so will be on a lot of sites already. It is maintained and mainly in Drupal 8 core. We will need a mandatory dependency for any module that defines a date field.

This change will also solve a lot of issues that have been present in previous versions (due to having to define our own date structures).

Done in the latest patch:
- Removes all of the previous custom date field code.
- Adds a field named "Date range"
- Adds an instance of this field to PM Project / PM Task / PM Ticket / PM Timetracking, and migrates data from the old custom fields
- Create separate fields to cope with Expense Date, and the three dates shown on invoices.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

juliangb’s picture

juliangb’s picture

Modules that need this:
- Expense (date)
- Invoice (request date, due date, payment date)
- Project (date begin, date end)
- Task (date begin, date end)
- Ticket (date begin, date end)
- Timetracking (date, time begin, time end)

That's more than I realised!

Once we've migrated these, there will also be some date functions to remove from pm.module.

juliangb’s picture

Assigned: Unassigned » juliangb
Issue summary: View changes

I'm actively working on this issue.

juliangb’s picture

Status: Active » Needs review
FileSize
54.99 KB

Uploading this initial patch mainly for personal testing.

So far - it removes all mention of the old custom date fields, adds a date range field and instance on the project node.

juliangb’s picture

Issue summary: View changes
FileSize
59.29 KB

Updated patch - now with update function for pm project instance. If this is working, that code can be copied to task and ticket.

dbt102’s picture

Testing -02 patch. Patch loaded though a lot of error messages popped up, seeming related to code not yet implemented for non-project modules. Hunks 1, 2 3 & 4 succeeded.

For project content types was able to add a new date field with all options selected (due date, etc.). Tested the pop-up calendar feature. Works great. really cool...

juliangb’s picture

Thanks for testing - glad that it looks helpful! I'm quite excited by how many opportunities this will open up (for example, much more flexible Gantt charts).

Please do post any error messages you get, and I'll see whether they are expected or not.

When I get a chance, I'll be rolling this patch out to the other non-project modules.

dbt102’s picture

ubuntu:david$ git apply -v pm-date-fields-02.patch
Here is copy of terminal printout when applying patch to a different dev install.

Checking patch pm.css...
warning: pm.css has type 100755, expected 100644
Checking patch pm.install...
warning: pm.install has type 100755, expected 100644
Checking patch pm.module...
warning: pm.module has type 100755, expected 100644
Checking patch pmexpense/pmexpense.install...
warning: pmexpense/pmexpense.install has type 100755, expected 100644
Checking patch pmexpense/pmexpense.module...
warning: pmexpense/pmexpense.module has type 100755, expected 100644
Checking patch pmexpense/pmexpense.views.inc...
warning: pmexpense/pmexpense.views.inc has type 100755, expected 100644
Checking patch pminvoice/pminvoice.install...
warning: pminvoice/pminvoice.install has type 100755, expected 100644
Checking patch pminvoice/pminvoice.module...
warning: pminvoice/pminvoice.module has type 100755, expected 100644
Checking patch pminvoice/pminvoice.theme.inc...
warning: pminvoice/pminvoice.theme.inc has type 100755, expected 100644
Checking patch pminvoice/pminvoice.views.inc...
warning: pminvoice/pminvoice.views.inc has type 100755, expected 100644
Checking patch pmproject/pmproject.install...
warning: pmproject/pmproject.install has type 100755, expected 100644
Checking patch pmproject/pmproject.module...
warning: pmproject/pmproject.module has type 100755, expected 100644
Checking patch pmproject/pmproject.views.inc...
warning: pmproject/pmproject.views.inc has type 100755, expected 100644
Checking patch pmtask/pmtask.module...
warning: pmtask/pmtask.module has type 100755, expected 100644
Checking patch pmtask/pmtask.views.inc...
warning: pmtask/pmtask.views.inc has type 100755, expected 100644
Checking patch pmticket/pmticket.module...
warning: pmticket/pmticket.module has type 100755, expected 100644
Checking patch pmticket/pmticket.views.inc...
warning: pmticket/pmticket.views.inc has type 100755, expected 100644
Checking patch pmtimetracking/pmtimetracking.module...
warning: pmtimetracking/pmtimetracking.module has type 100755, expected 100644
Checking patch pmtimetracking/pmtimetracking.views.inc...
warning: pmtimetracking/pmtimetracking.views.inc has type 100755, expected 100644
Applied patch pm.css cleanly.
Applied patch pm.install cleanly.
Applied patch pm.module cleanly.
Applied patch pmexpense/pmexpense.install cleanly.
Applied patch pmexpense/pmexpense.module cleanly.
Applied patch pmexpense/pmexpense.views.inc cleanly.
Applied patch pminvoice/pminvoice.install cleanly.
Applied patch pminvoice/pminvoice.module cleanly.
Applied patch pminvoice/pminvoice.theme.inc cleanly.
Applied patch pminvoice/pminvoice.views.inc cleanly.
Applied patch pmproject/pmproject.install cleanly.
Applied patch pmproject/pmproject.module cleanly.
Applied patch pmproject/pmproject.views.inc cleanly.
Applied patch pmtask/pmtask.module cleanly.
Applied patch pmtask/pmtask.views.inc cleanly.
Applied patch pmticket/pmticket.module cleanly.
Applied patch pmticket/pmticket.views.inc cleanly.
Applied patch pmtimetracking/pmtimetracking.module cleanly.
Applied patch pmtimetracking/pmtimetracking.views.inc cleanly.
ubuntu:david$

juliangb’s picture

Ok, ignore those warnings.

It looks like the files in your system have slightly looser security permissions than the ones in mine.

It isn't connected to this patch.

juliangb’s picture

Issue summary: View changes
FileSize
77 KB

Uploading latest patch, so that it can be tested by the bot and to record progress.

juliangb’s picture

FileSize
76.99 KB

Minor edits on this patch.

juliangb’s picture

Issue summary: View changes
FileSize
97.29 KB

Another patch. Should be "feature complete" now, so will just have to work out where the bugs are.

juliangb’s picture

NB: Running the patch through coder indicates no issues (all false positives).

One, I will need to add an ignore flag for, and this is using date() rather than Drupal's format_date(). This is to ensure that the conversion of fields in the update functions doesn't do anything funny with timezones.

juliangb’s picture

FileSize
99.19 KB

Updated patch, bug fixes only.

juliangb’s picture

FileSize
99.2 KB

Another updated patch, with bug fixes.

juliangb’s picture

Status of the patch:
- It works, and I've tested it on both a fresh installation and upgrade. That said, I haven't put it through heavy testing of migrating data. Hopefully someone who often uses timezones can feedback on that.
- Default values: Invoice due date should be relative (30 days after request used to be the default). Payment date should not have a default, and should not be a required field.
- Date range field, probably doesn't need the term "range" in the label.

I will probably commit this once I am happy with it, without giving it much time in the queue. It is a large patch and so will make it hard to write other patches in the meantime.

juliangb’s picture

FileSize
100.07 KB

Final patch.

juliangb’s picture

Status: Needs review » Fixed

Committed that final patch.

juliangb’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

  • Commit 4aad006 on 7.x-1.x, 7.x-2.x by juliangb:
    Issue #1929158 by juliangb: Use date fields from the date module.