Closed (fixed)
Project:
Translation Management Tool
Version:
7.x-1.x-dev
Component:
User interface
Priority:
Major
Category:
Task
Assigned:
Reporter:
Created:
25 Jan 2012 at 14:21 UTC
Updated:
10 Mar 2014 at 19:30 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
schnitzel commented+1
Comment #2
fubhy commented+1
Comment #3
fubhy commentedLets please do this as early as possible. Please also take a look at this for further cleanup issues for the UI part of TMGMT: #1420644: Move all the overview views out of the core UI module
Comment #4
jose reyero commentedAgree, separate module.
Comment #5
schnitzel commentedComment #6
berdirComment #7
miro_dietikerIt turns out that this is an expectation of the users.
Adding different content in multiple steps, before they launch the job.
Comment #8
miro_dietikerAgain, requested with high priority. :-)
Comment #9
miro_dietikerI guess we should set the priority here accordingly. This is a major UI / UX concept.
Comment #10
berdirThis patch is the code written by Byron Sorrels, published on https://github.com/byronsorrells/tmgmt_cart.
We agreed that we will continue the development here, so posting this patch as a starting point.
I reviewed it and identified the major elements that need to be resolved to make this generally useful and not just for the limited use case that they had. Looks like they did a bit of work since I did that, so need to review the changes but I think it's still accurate.
A better way to inject the card handling into the various checkout forms. there are also the translate tabs, the upcoming potx integration and so on. tmgmt_cart can't manually hack itself into all those places.
This either requires some API that's part of tmgmt_ui and cart can hook into, or we'd just make the cart part of tmgmt_ui. Not sure yet, but we need some sort of standardization for source plugin UI's so that they can easily support both immediate checkout and add to cart wherever they create job items/jobs
We need to correctly detect the source language, including the fact that there could be multiple source languages.
This really means that instead of tracking an arbitrary array, we need to track job items in the cart. This is a bit of an overhead (I'd imagine we create and save them and then store the ID's in the session and need to load them when we need them), but it solves a whole bunch of problems and results in better UX. a) The unreliable (source types are not unique across plugins) source map shuffling can be dropped. b) We can display the same label and information in the block as on the checkout page. It will also require some changes/additionals to job items, for example, we need a way to ask them what their source language is, right now, there is no way to ask for this information. Possibly additional things that I can't think of right now. That API would also help with 1. as we could standardize more of the logic in the plugin specific job/item creation code
When we have job items and can get their source language, we can loop over them, and create as many jobs with the corresponding source language as we have to. In your case, this should give the same result, a single job with source en, assuming you only selected those sources.
This needs: #2155203: Extend source plugins with methods to get source language and existing translations
The checkout will need to go through the checkout API's
Instead of the hardcoded checkout, we need to go through the helper functions, so that we can direct users through the checkout process if they need to select/configure stuff/have multiple translators.
We will also want to support translating into multiple target languages with multiple jobs. This can wait for a later phase/iteration.
I'd leave this out for now, but we could then add a multi-value target language selector and then create jobs for every necessary source -> target combination, excluding those that are already in the desired target language(s). A simple version of this shouldn't be too hard, but there are a lot of fancy ideas of extend it, like giving the user more control if he e.g. wants to use an existing translation to translate something into another language and so on. But I think the above would already be pretty cool for a first version (a first post-commit update version ;))
Comment #11
bsorrells commentedIn our use case, we exclusively use the /admin/tmgmt/sources UI to request translations. So far, our biggest need to is to provide labels for the items in the cart. After adding several items from different sources and across pagination, it starts to get very difficult to know what you've added to the cart. I attached a screen shot to show the cart UI.
Should we prioritize the items listed in #10?
Regarding multiple target languages, we did implement that a simple way. In our case, 99.99% of the time we want to translate something into all enabled languages. I used the language neutral constant as the target language, created a single parent job, and then created a "sub job" for each language code that's enabled (with a reference to the parent job and an indication that it's a subjob. This allows us to poll for one job instead of 35. We ingest translations for all 35 languages with that one request and then iterate over it.
Comment #12
berdirAssigning this to me. Need to play with this a bit and think about how to continue, the source language issue referenced above has been committed.
Comment #13
blueminds commentedFirst step - integrate with our new job item language API; use job items in cart
Comment #14
berdirFirst, quick review.
Hm, this fails because there was no job, right?
This is problematic, because both are correct. Once there is a job, only the source language of the job is relevant, not the one of the job item/source.
For now, I'd suggest you simply check if there is a job and fall back to the source language if not.
$key isn't unique, I would just do cart[] =
Which means this won't work anymore that easily but that's true anyway, needs the plugin, type and id.
You will have to load the job items and check them.
I would also recommend to use the same variable names as $job->addItem(), $plugin, $item_type and $item_id.
Comment #15
blueminds commentedhere it comes... no interdiff provided as with merging the tmgmt_cart/ui it is basically all changed.
Comment #16
blueminds commented- now we can request translation to multiple target languages
- removed the message about not checked out items, added info about ignoring items with same source/target
- updated add to cart message that displays the actual number of added items (not working form node source => vbo)
Comment #18
blueminds commentedComment #20
blueminds commentedComment #21
berdirLooks good, nice test coverage, a few things below, but nothing too big I think.
We should be able to revert this change now.
The moved comment here seems a bit strange, that actually belongs to the code below, the entity_extract_ids() was just a necessary step for that. In short, don't move the comment.
More of those below :)
Also revert :)
And... here
Based on what is the order here? Could this possibly lead to random fails? (sql sort is not stable if there is no sort condition or one where the node have the same value).
maybe just create two nodes to begin and create the third afterwards to make sure.
Wondering how it would look if we made this the description of the language selector?
Let's add a method to return the count, then it can do that directly on the ID's, this always needs to load all those job items, including their possibly large data.
Hm, how useful is this really? We really just save a single, easy line and add a whole function for it.
This is a bit fragile with empty ID checks, optional validates and hardcoded assumptions about where the items are stored.
We should at least make sure that it is properly documented what the requirements for using this are.
If we want to simplify the code here, why not do $cart->addJobItem($plugin, $item_type, $source_id) ? Maybe as a separate method.
We could even say that that function checks this by default.
Comment #22
blueminds commented6. - there is sort by Post date. Could not come up with anything better, will think about it.
The rest is implemented, let's see if test bot is happy.
Comment #24
berdirHm, that's a fun one :)
(not actual code)
$cart->addItem();
$cart->count(); -> 1
$cart->addItem();
$cart->count(); -> 1
:)
See http://programmers.stackexchange.com/questions/80084/is-premature-optimi...
Drop $this->count. It's not worth the additional complexity it would require to work reliably unless we call it hundreds of times and I don't think we do :)
Hm, not sure if that is what I meant/an improvement.
The main thing I requested is good documentation:
There are two main cases where this can be used, and it's OK to limit it to that.
But we need to document what it means. For example, if you use this on an overview, you need to need to ensure that the ID's will be in the correctly named form element. Also include two sample calls with in @code @endcode fragements.
And thinking about that, what would be great is starting a new @defgroup for this, just copy an example in tmgmt.api.php and then add an @ingroup tmgmt_cart to all relevant functions and classes.
Ah, I guess this and the example below are the main reasons you added helper function ;) Would a loop be easier here?
Unnecessary empty line left-over after the revert.
This looks wrong, the translate tab version shouldn't have this?
See above. The most important is documenting how the function works and what the requirements for using it are. Sorry if I was unclear.
Same left-over here.
Using singular/plural is one way to differentiate the two methods.
TMGMTJob does it differently, it uses addItem($plugin, ...) and addExistingItem($item). The main reason there was that we already had addItem() and needed a method name for the existing one. It might or might not be better.. but it might make sense to be consistent. Let's discuss tomorrow.
Looks like you left the function in place?
This one still has a slow count()
Adding them once should be enough :)
You still need the if () I think but just to increase a counter?
if ($cart->add...) {
$count++;
}
Comment #25
blueminds commentedyup, i guess that coding after few beers isnt that good idea :)
Comment #26
blueminds commentedComment #28
blueminds commentedComment #29
blueminds commentedwith enabled all tests
Comment #30
berdirDid extensive testing of this, improved the submit function and some other places and added comments.
Comment #32
miro_dietikerI see lots of D8 stuff in this patch. And a totally different nid / naming. ;-)
#2155635: Allow plugin managers to opt in to cache clear during module install
From blueminds patch i have few questions thingies..
This is not new, but it's strange that a getData() implicitly saves an item.
Strance comment wrapping. Hmm?
new one ... and missing "."
Comment #33
berdirYeah, too tired to be capable of reading patch names. Will address the feedback above later.
Comment #34
berdir1. Yeah, not sure if we need it, the idea was that it is transparent and once called, is saved. However, now that we do this already in save() assuming there's a job makes this pointless as it actually means we start a save, then save again which makes the actual saving an update. Not related.
2. Fixed.
3. Fixed as part of 2.
Comment #35
miro_dietikerLooks nice.
For sake of completeness: The cart is currently sequentially ordered: New items append.
Otherwise we should push this. As a next step we should create some followups for the current known Cart UX issues.
There are still some things like ordering, having multiple (named?) carts, splitting carts, global cart (not from session)?, ...
Unsure if we need all that, but we should be open to discuss such ideas to possibly improve UX even further.
And sure, it is not related to V1! :-)
Comment #36
berdirDear sirs and madams. We have a cart :)
Thanks everyone! Also made sure to credit byron sorrels as well.
@Miro. The job item order is also not sorted in any way inside a job,
Comment #37
bsorrells commentedAwesome!
Just applied the patch (#34) and trying it out. I love the tab idea! I'm able to successfully add five items to my cart from various sources. The tab says Cart (5), but I get an error when trying to view the cart:
Fatal error: Call to undefined method TMGMTJobItem::getSourceLangCode() in www/sites/all/modules/contrib/tmgmt/sources/locale/tmgmt_locale.plugin.inc on line 86
Are you able to reproduce?
Comment #38
blueminds commented@bsorrells the getSourceLangCode() has been added among others in #2155203: Extend source plugins with methods to get source language and existing translations. Please use the latest status from the repository.