Experimental project

This is a sandbox project, which contains experimental code for developer use only.

Synopsis

I want to be able to use Views Bulk Operations to update the office hours on a bunch of nodes.

Note that this module does not work yet! This initial attempt is posted here so that I can get feedback from others.

Requirements

  • Drupal 7 core's Field UI module is needed to add an Office Hours field instance to an entity.

Roadmap

This module has no stable branch yet, but work is occurring on the 1.x branch.

Known problems

This module does not work yet!

Credits

Current co-maintainers:

See the bottom of this page for a list of organizations who have supported this project.

Gittip/Flattr/Paypal

The current co-maintainers are not currently accepting donations.

However, if you are willing to pay this module's co-maintainers to work on a bug that affects your project, or add a feature you require, please contact the co-maintainers directly using the contact form on their respective Drupal.org user account pages.

Help wanted!

Maintaining a project can be a lot of work, and the current co-maintainers of this project have full-time jobs, are not paid to maintain this module, and maintain a few other projects besides this one.

More co-maintainers to help triage issues, test patches for regressions, and add features would be greatly appreciated and would help us to resolve issues faster! If you are interested in becoming a co-maintainer, please open an issue asking to become one!

I don't know of any similar projects at this time, so if you find one, please let me know by adding an issue!

Dependencies

This module does not depend on an external service (e.g. SaaS) to be fully functional.

Restrictions

This module has no artificial restrictions: the version available from Drupal.org has full functionality. No paid version is available.


Instructions

  1. Download and install Drupal 7.23.
  2. Download and install Date, Entity, Rules, Views and Views Bulk Operations:

    drush -y dl date-7.x-2.6 entity-7.x-1.2 rules-7.x-2.3 views-7.x-3.7 views_bulk_operations-7.x-3.1
    
  3. Download this module (it's a fork of office_hours-7.x-1.x)

    cd /webroot/sites/all/modules
    git clone --branch 7.x-1.x http://git.drupal.org/sandbox/mparker17/2084109.git office_hours
    
  4. Enable all the modules

    drush -y en date_api entity entity_token field field_ui node office_hours rules rules_admin views views_ui views_bulk_operations
    
  5. Create a content type named "Shop". Add a field of type "Office hours" named "Shop working hours" (machine name must be field_shop_working_hours). On the Field settings page, set "Number of blocks" to "1". Leave everything else at the default.

  6. Create a piece of shop content. Set hours in at least one of the fields.
  7. Go to Administration -> Configuration -> Workflow -> Rules -> Components. Click "Add new component":
    • Component plugin = Rule.
    • Name = "Set shop working hours"
    • Variables:
      • Data type = Entity -> Node; Label = Node to change; Machine name = node; Usage = Parameter
      • Data type = Weekly office hours; Label = New shop working hours; Machine name = new_office_hours; Usage = Parameter
    • Add a condition:
      • Select the condition to add = Entities -> Entity has field
      • Entity -> Data selector = node
      • Field -> Value = field_shop_working_hours
      • Click "Save"
    • Add an action:
      • Select the action to add = Set a data value
      • Data (Specifies the data to be modified using a data selector) -> Data selector = node:field-shop-working-hours
      • Value (The new value to set for the specified data) -> Click "Switch to data selection" and set Data selector = new-office-hours
      • Click "Save"
    • Click "Save changes" on the rule.
  8. Add a new view:
    • View name = "Shops"
    • Show Content of type Shop sorted by Newest first.
    • Create a page:
      • Page title = "Shops"
      • Path = "shops"
      • Display format: Table of fields
      • Items to display = "10".
      • Click "Continue & edit"
    • Add a field of type "Bulk operations: Content". In "Selected bulk operations", check Set shop working hours. Leave the checkboxes that appear under it unchecked.

Testing it out

  1. Visit the view (http://yoursite.example.com/shops).
  2. Check the checkbox next to your shop content. From the "Operations" drop-down, choose Set shop working hours and click "Execute".
  3. Enter working hours (different from what you added in step 6) and click "Next".
  4. Click "Confirm" on the confirmation page.

What's wrong

It's a combination of two things:

  • Firstly, the office_hours field doesn't work like regular fields, so I have to modify all the values for a field at once.
    Even though the office_hours field widget appears to present a single field-collection that prompts a user to enter opening hours an entire week (the widget doesn't have an "Add another item" button and the UI for the most part treats it as a single thing), the office_hours field widget actually stores at least 7 field values at once.
  • I'm pretty sure I have to use the advanced features of rules' data types (UI classes and Data wrapper classes), but I don't know how to do it because there isn't much documentation.

For more in-depth information, read the comments in office_hours.rules.inc.

Supporting organizations: 
helped mparker17 to come up with the concept and work on the module.

Project information

  • caution Unsupported
    Not supported (i.e. abandoned), and no longer being developed. Learn more about dealing with unsupported (abandoned) projects
  • caution Maintenance fixes only
    Considered feature-complete by its maintainers.
  • Created by mparker17 on , updated