The 3.x version of flag introduces major changes, and requires quite a few changes in flag weights. I would suggest creating a new branch of flag weights, probably a 3.x branch so that the version numbers match up. Patch forthcoming.

Comments

acrollet’s picture

Status: Active » Needs review
StatusFileSize
new10.6 KB

patch attached for review.

areikiera’s picture

This works great for me so far. Thanks acrollet!

One of the features of Flag 3 is that is supports unique anonymous flagging (with the help of the Session API module), but this module stores information by UID, and so all changes to a Flags Weight change for all anonymous users who have it flagged. There is an SID field and I wonder if that could be used to store weights instead (or in addition to), and what changes would be required to support that.

I'm not a module developer, but would be happy to do what I can to help test and contribute to having this ability.

acrollet’s picture

areikiera: thanks for reviewing. IMO that should be treated as a separate feature request once there's a -dev branch of 3-x. If this patch works correctly for you as an update of the 2.x compatible module, perhaps you could set this issue to RTBC so that it can get in?

areikiera’s picture

Status: Needs review » Reviewed & tested by the community

Certainly! The updates to the draggableviews handler seem to be working as well. Thanks again for the patch!

I think this is an incredibly helpful module (big thank you to lyricmz), and getting it to work with the latest version of Flag would be greatly appreciated! I'd be happy to help with updated documentation if it helps lighten the load and helps get an updated version out more quickly. I agree with acrollet that a 3.x branch would make sense.

Thanks!

areikiera’s picture

StatusFileSize
new4.71 KB

While this is in the works, I did want to ask, should the flag weight be mapped to the draggableviews weight? My flag weights are updated with the proper weight after reordering, but I've noticed that the draggableviews weight field value doesn't match the flag weight field. My concern there is that if a user clicks "Show row weights" and tries to reorder through those values, it doesn't save in the expected order. I've attached a screenshot of what I'm seeing.

areikiera’s picture

Any updates on this? Thanks!

areikiera’s picture

Really hope the 3.x branch will be released soon! Please let me know if there is anything I can do to help!

arrubiu’s picture

Any news?

Andre-B’s picture

patch does not apply without problems, since it introduces whitespace errors:

Andres-MacBook-Pro:flag_weights andrebaumeier$ git apply flag_weights-support_flag_7x_3x-1877304-1.patch 
sites/all/modules/flag_weights/flag_weights-support_flag_7x_3x-1877304-1.patch:271: space before tab in indent.
    	flag_weights_set_weight($fid, $flag->entity_type, $item['id'], $uid, $item['weight']);
warning: 1 line adds whitespace errors.
harcher’s picture

update?

robin van emden’s picture

Issue summary: View changes

Was able to make Flag 7.x-3.4, draggableviews 7.x-2.x-dev & flag_weights .x-1.x-dev work by applying this patch, together with #1545968-9: Add compability with DraggableViews 2.x

jay.lee.bio’s picture

#1 worked perfectly for me. I didn't get the error at #9.

robloach’s picture

StatusFileSize
new11.77 KB

Updated, I believe.

jay.lee.bio’s picture

After disabling this module and not noticing any difference, I am a bit confused. Am I correct to assume that this module is now obsolete, since DraggableViews also has its own weight field? Or did I miss something?

robloach’s picture

After disabling this module and not noticing any difference, I am a bit confused. Am I correct to assume that this module is now obsolete, since DraggableViews also has its own weight field? Or did I miss something?

Flag Weights provides a weight field for user's set Flag, while DraggableView's weight field is for the View itself. While they are similar, they are used and architected different ways.

calbasi’s picture

It runs OK on Flag 7.x-3.6
Thanks a lot.

ericjgruber’s picture

I've applied the patch above and sadly, it's not working for me. I keep getting this issue:

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'default_weight' in 'field list': SELECT default_weight FROM {flag} WHERE fid = :fid; Array ( [:fid] => ) in _flag_weights_get_default_weight() (line 181 of /Users/ericgruber/Projects/AO/docroot/sites/all/modules/contrib/flag_weights/flag_weights.module).

shawngo’s picture

I ended up applying the patch manually against the latest dev branch (2013-Sep-30) and was getting the error:

Notice: Undefined property: stdClass::$flagging_node_entity_id in draggableviews_handler_flag_weights->set() (line 55 of sites/all/modules/flag_weights/handlers/draggableviews_handler_flag_weights.inc).

I made one change to draggableviews_handler_flag_weights.inc which correctly saved the flag weights and listed them in the correct weighted order:

      // Find the Entity ID.
      $id = $item['id'];
      if (!empty($result)) {
        foreach ($result as $result_item) {
          $flag_id = isset($result_item->flagging_node_flagging_id) ? $result_item->flagging_node_flagging_id : null;
          if ($item['id'] == $flag_id) {
-           $id = $result_item->flagging_node_entity_id;
+           $id = $result_item->nid;
          }
        }
      }

I'm not sure how this would be handled using any other kind of entity (specifically pulling data from $result_item->nid). And not knowing why my patch didn't apply using git I'm not sure what might have changed between the dev branch and the patch in #13.

plusproduit’s picture

Hello,

After applying the patch in #13 and Shawngo's patch in #18 I got the module to work with Flag 3.6 and latest Draggable views / views.

Please note that you must create the draggable view in "Master" display, and then add a page display. It's a Draggable views issue.

This module adds a very nice feature, and works with anonymous sessions as well (Session API required)

Thanks a lot!

zterry95’s picture

StatusFileSize
new13.12 KB

the patch always not working for me.
So I apply the patch by hand. here is the complete module tarball.

here is the working code for me. Hope it helps.
Looks it's difficult to request co-maintainer for this module. so I put it on the github.com
https://github.com/terryzwt/flag_weights

gumanov’s picture

If anyone is interested, I posted a patch to get the DraggableViews (7.x-2.1) integration to work properly for other entity types, not just 'nodes'.
See here

nord102’s picture

After applying #1, I was able to correctly install and enable Flag Weights without error.

However, when attempting to save my Flag Weights, I noticed that they weren't being saved. I currently have a view that has a Draggableviews: Flags field using the Flag Weight sort handler.

I noticed that in draggableviews_handler_flag_weights, the $item['id'] passed is the flagging_id as opposed to the entity_id. This was the reason that the flag weights weren't saving correctly.

Unsure if this situation/use case is too specific but I have attached a patch to #1 that uses flagging_id instead of entity_id in flag_weights_set_weight.

lbainbridge’s picture

Here's a re-roll of the patch in #1 that includes the changes proposed by nord102 in #22.

patoshi’s picture

Is there a quick tutorial on how to set this up? I'm able to expose the draggable handlebars to reorder the rows, but it doesnt save. I'm trying to use this for "flag lists" module.

I'm not sure if its even compatible. Anyone can list out how to go about setting up flag weights?

patoshi’s picture

Actually i just used draggableviews module only without the need for this module. it works with the flag list module.