1

I’m working on an admin interface, where admin users log in to desk content for their newspaper’s mobile app. My scenario is pretty specific, so bear with me;

I have a collection of items. Items are sorted on priority (PN), set by the admin user. Most of the items are “normal”; they are responsible for referring to one piece of content (an article, for instance), or holding on to some values input by the admin user.

Then there are these special items that are configured so that they refer to another collection – a collection that will be embedded and flattened into the collection itself, when rendered by the end user/consumer. The items from the referred collection will have their own priorities pre-set, and distributed by a step value (SN).


To ‘illustrate’:

Collection, sorted on priority (admin user)

Item                            P10
Special item                    P15 S10
Item                            P20
Item                            P30

Becomes the resulting collection (end user)

Item                            P10
Special item     P15+(S10*0)    P15
Item                            P20
Special item     P15+(S10*1)    P25
Item                            P30
Special item     P15+(S10*2)    P35
Special item     P15+(S10*3)    P45
Special item     P15+(S10*4)    P55

What I already have

  • This all works on the back-end
  • A separate preview mode – I can just ask for the collection rendered out as if I were an end user

What I want

  • Shadow elements rendered out into the collection when in admin mode, to show how a special item’s referred collection’s items will merge into and spread out into the collection at hand

To clarify, since there have been some confusion in other channels:

I don’t have two collections. I have one collection, and one or more of its items could have configuration that will eventually, for the end user, lead to more items being mixed into and distributed in that one collection.


With Backbone (and Marionette), I know how to add specific types of children into a collection, and how to strip those away when syncing to server. My question is more about how to keep everything in sync when an admin user changes priority or step values, and how do I make all the added rendering efficient?

How would you go about doing something like this?

Hein Haraldson Berg
  • 1,108
  • 11
  • 24
  • Have the *shadow* models have a *shadow* property and treat them as such based on that..? – T J Dec 03 '15 at 16:47
  • @T J What I’m asking her is more in the lines of how would I go about adding them in the first place, always at the right indexes, and with good performance? – Hein Haraldson Berg Dec 04 '15 at 08:49
  • Add them just like any other models and define a comparator to keep them at right index..? – T J Dec 04 '15 at 08:51
  • Their positions are determined by a whole shebang of factors, and I will need some sort of controller on top of my collection to make sure they keep updated as I do changes, go away if I remove that kind of special card etc. I know comparators, model properties, how to render out different childViews etc., what I’m asking is general advice on the architecture. – Hein Haraldson Berg Dec 04 '15 at 08:58

0 Answers0