Hey,

I have the 7.x-2.0-beta5 version of the flag module installed and the latest dev release of flag weights.
In my use case, flag weights would only serve to sort the order in the flag vertical tab on node/add/*
Optionally it would be nice to have the same order at /admin/structure/flags but that's not a necessity.

I have 5 flags on a content type for workflow purposes but the flags appear in the order I created them (which wasn't in the desired order) and not in the order to which I have set the flag weights.

If I'm not mistaking the flag weights module should be capable of altering the order in which the flags appear in the flag vertical tab on node/add/* ...or did I misunderstand that perhaps?

thanks for any advice or fix you might have.

Comments

lyricnz’s picture

Project: Flag Weights » Flag
Version: 7.x-1.x-dev » 7.x-2.x-dev
Category: bug » feature

Flag Weights module is about ordering the flagged items (eg: the items in "Your Bookmarks"), not weighting the different Flags relative to each other. Your question sounds like a feature-request to Flags module: I've changed it to that. I just looked at the code for Flag module, and the most obvious implementation would provide ordering wherever a list of flags is shown, including/admin/structure/flags.

lyricnz’s picture

Status: Active » Needs review
StatusFileSize
new2.51 KB

Here's a patch that adds a "weight" to each Flag, used for sorting a list of flags in the UI, for example:
- on the flag admin page
- on the list of flags on the node-edit form

lyricnz’s picture

StatusFileSize
new2.28 KB

Remove unnecessary whitespace change.

lyricnz’s picture

StatusFileSize
new2.03 KB

Remove another unnecessary change. Less is best :)

sjugge’s picture

Thanks for moving my post to the appropriate module and category and putting in the effort for the patch.

I'm sorry to say I'm not yet mastering patching modules quite yet so I won't be able to test your patch... to my shame. It's high on my list of priorities to get my head around patching but for now I'll just have to sit by like the noob that I am on that front until someone more skilled stops by and wants to spend some time on applying and testing this patch. It would be a nice little piece of bling to have and make the flag module even more awesome.

lyricnz’s picture

Applying a patch is pretty easy - you should learn :) Try looking at http://drupal.org/node/620014 or searching the web.

sjugge’s picture

I've applied patch in #4 to the latest .dev (and .alpha as well) release of the flag module using the command line (which seems to be way easier then in Eclipse which I was attempting to do before) but got the following error statement in my terminal.app:

patching file flag.inc
Hunk #1 succeeded at 198 (offset 5 lines).
Hunk #2 succeeded at 1874 (offset 5 lines).
patching file flag.module
Hunk #1 succeeded at 1580 (offset 92 lines).
Hunk #2 FAILED at 1616.
1 out of 2 hunks FAILED -- saving rejects to file flag.module.rej
can't find file to patch at input line 53
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/includes/flag.admin.inc b/includes/flag.admin.inc
|index 8ff9ffa..68b9ea2 100644
|--- a/includes/flag.admin.inc
|+++ b/includes/flag.admin.inc
--------------------------

I have a Flag weight field at /admin/structure/flags/manage/flag_name (with flag_weights module enabled) which allows me to set and alter the weight for each flag but it doesn't seem to have any effect on the display at /admin/structure/flags or node/*/edit.

I figured I might be patching the wrong version so I swapped the patched version of the .dev and .alpha (and vice versa) release but got the following notice: "Warning: uasort() expects parameter 2 to be a valid callback, function '_flag_compare_weight' not found or invalid function name in flag_get_flags() (line 1584 of .../sites/all/modules/flag/flag.module)."

Maybe I didn't apply the patch correctly, or to the right release.
Maybe the statement of the command line or error notice will help you with fine tuning the patch.

Thanks again for you effort.

lyricnz’s picture

The patch was not applied correctly - no point in testing anything until it is. It works perfectly here.

lyricnz:modules simonroberts$ pwd
/Users/simonroberts/htdocs/drupal7/sites/all/modules
lyricnz:modules simonroberts$ wget -nv http://ftp.drupal.org/files/projects/flag-7.x-2.x-dev.tar.gz
2011-05-31 16:15:49 URL:http://ftp.drupal.org/files/projects/flag-7.x-2.x-dev.tar.gz [74012/74012] -> "flag-7.x-2.x-dev.tar.gz" [1]
lyricnz:modules simonroberts$ tar xfz flag-7.x-2.x-dev.tar.gz 
lyricnz:modules simonroberts$ cd flag
lyricnz:flag simonroberts$ wget -nv http://drupal.org/files/issues/flag-ordering-1159470_1.patch
2011-05-31 16:16:14 URL:http://drupal.org/files/issues/flag-ordering-1159470_1.patch [2074/2074] -> "flag-ordering-1159470_1.patch" [1]
lyricnz:flag simonroberts$ patch -p1 < flag-ordering-1159470_1.patch 
patching file flag.inc
patching file flag.module
patching file includes/flag.admin.inc
lyricnz:flag simonroberts$ 
sjugge’s picture

Apparently I didn't have the -p1 in my command line when applying the patch earlier, a lesson learned, don't learn to apply patches with the command line at 6am ;)

The patch works like a charm for the display at /admin/structure/flags, node/add/* & node/*/edit. Good stuff, I don't see any notices or bugs pop up or pages imploding after applying the patch at first sight.

Thanks for your help, hopefully the flag module will get some lovin' soon so this can be committed.

lyricnz’s picture

@sjugge if you reviewed and tested the patch, please set it to "Reviewed and Tested by the Community"

sjugge’s picture

Since the patch hasn't "received a thorough review and test by one or more experienced developers" (I don't consider myself to be one), I left the status to "needs review" conform to the issue cue handbook. I guess if you tested out the patch yourself it can be marked as such seeing you have quite some experience under your belt ;)

lyricnz’s picture

I can't RTBC my own patches.

sjugge’s picture

Status: Needs review » Reviewed & tested by the community
quicksketch’s picture

I hadn't seen this issue, the feature that's written here I would have expected would be in the older issue at #307839: Support weights. Since this issue has a patch though, I've marked that one duplicate.

quicksketch’s picture

Status: Reviewed & tested by the community » Needs work

This patch does work and gets the bare minimum of functionality need for Flags having weights, but it's lacking what is considered to be expected behavior at this point with any thing that has "weight" in Drupal. The actual "weight" field should be removed from the flag configuration itself and instead set from the main list of Flags. Just like with blocks, menu items, fields, or taxonomy terms, users never actually use the "weight" field, they use the tabledrag mechanism to set the position. Many users don't understand "weight", and they shouldn't have to.

quicksketch’s picture

Status: Needs work » Fixed
StatusFileSize
new7.74 KB
new6.93 KB

I've revised the patch to replace the "Weight" field on each individual flag form with the typical drag-and-drop handles on the listing of all flags. Thanks lyricnz and sjugge for the original patch and reviewing. I've credited lyricnz in the commit. Committed attached patches to both 2.x branches.

quicksketch’s picture

Title: weights have no effect at node/add/* & /admin/structure/flags » Add ability to adjust flag order on node/add/* & /admin/structure/flags pages

Status: Fixed » Closed (fixed)

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