Closed (fixed)
Project:
DraggableViews
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
27 Nov 2011 at 08:23 UTC
Updated:
22 Feb 2016 at 18:42 UTC
Jump to comment: Most recent
Issue for 7.x-2.x branch.
Write Field API handler (saves to integer field).
Comments
Comment #1
ygerasimov commentedComment #2
ygerasimov commentedI have pushed initial patch to separate branch "handlers". Please test.
Comment #3
ygerasimov commentedBranch "handlers" merged with 7.x-2.x.
Comment #4
julien.reulos commentedHi,
I use the last 7.x-2.x version from today 03/06/2012 and I applied the patch from http://drupal.org/node/1458912#comment-5693992.
I have a view with the FieldAPI handler option, an integer type Field to base the rows order on, named "Order". In my database the "Order" field value for these rows goes from "1" to "135".
So first I click on the header to order the rows by "Order" ascendant. The view is ordering as expected. I click "Show row height". The Weight value is "-135" for every row.
Then I move some rows in the table. Now the Weight value goes from "-135" to "-1". Ok.
When I save the view, the update in the "Order" Field table in the database is working as expected, as the value for the rows I moved is correctly updated. There is only one problem : the values are now going from "0" to "134" (they should go from "1" to "135").
Thanks for this great module!
Comment #5
ygerasimov commented@julien.reulos please advise why it is a problem for you that weights are from '0' to '134' and not from '1' to '135'? I think it is done by tabledrag.js that sets the values in selectboxes (please pay attention that values and labels in weight selectboxes are different i.e. -134 can be 0 as value).
Comment #6
julien.reulos commentedHello,
I think it's a problem because the module should not alter the way the Field values you use in the view as handler were previously numbered in the database.
If the values in the view table are going from "1" to "10", and you are reordering them, the first row should keep this "1" value and the last one the "10" value.
So, more concretely, the problem is that these integers are shown to the anonymous users in nodes. This people doesn't expect that the first node be "tagged" as "0". They expected "1" instead.
Using some Field values to order the table, I expected that the module would use these values to reorder the table + update the values in the database with the same ones.
Thanks for the tip about tabledrag.js. I will have a look into it.
(yes, the "0" value appears in the database table while the "-134" one appears in the selectbox table row.)
Comment #7
murzUpdated to current dev version, I see FieldAPI but have the problem: I have integer field "Weight" and more than 50 nodes, and have problem with view using pager "10 items".
If I show all items in view (without pager), all looks good.
If I set pager to "10 items", and show weight field, I see that this field have selectlist with -10 to 10 values, but some first values are equal, so first six items have same -10 values, second several have same -9, etc. Is it normal or I do something wrong?
Comment #8
ygerasimov commented@Murz, I think solution for your case should be to use one view to set the order that will have no limits on pager and the other one with 10 items pager for display. In this case your sorting order will be correct.
Comment #9
murzI already have different views for viewing and ordering, so i can't use ordering via Views native api.
At 50+ items list without pager will work normally, but I plan to have 1000+ nodes for ordering, and saving so much nodes in one step will be not so good for performance. Is updating order do full node_save or only update one database table?
As I try earlier, on DraggableViews 1.x ordering with pager works normally, any chance that this will work good too on 2.x?
I think we can get count of rows in current page, and build order field data between them, and on save - get min and max values from each item, and build new ordered values. This must solve problem with ordering and pagers.
Comment #10
ygerasimov commented@Murz, at the moment Field API handler does full node_save. But I think you can write your own handler to do only one database table update and clear nodes caches.
At the moment pager is not supported in 2.x branch. I am glad to cooperate in order to make it working.
Comment #11
murzHere is quick example how to update field without do full node_save:
I'll try to implement new handler for DraggableViews that do saves via this method.
Comment #13
sebas5384 commentedHey @Murz! thanks your code example.
Did you make the handler or a module to do that? because this is really an issue for me, doesn't make sense a full save to only update ONE field.
The thing is, modules such as search_api use hooks like hook_entity_update() that only are fired when a full save is done, so, if we change to an updating field only process, it will impact in everything else that is integrated with. In this case with search_api we will loose the immediately update in your search.
Maybe we can do some manual invokes of that kind of hooks?
thanks!
Comment #14
dreamer777 commentedI've implemented the following code in fieldapi handler to update quickly field collection items. It was faster then in general.
Can anybody see it in case of Node entities? Use it with caution - not to erase node contents.