How can I ensure that NSOutlineView.parent(forItem:) returns the correct parent object if the same child object exists multiple times? - nsoutlineview

I have just encountered a problem when using NSOutlineView and wonder is anyone has a solution.
I have a hierarchy of items and the lowest nodes are objects that can appear in more than one location.
For example:
Country
Town
Car Manufacturer
USA
Chicago
Toyota
Dallas
Toyota
Now if the user selects the 'Toyota' items in the list and if I then try and find the parent for the selected item using the outlineView.parent(forItem:) API it will always return the same parent item, presumably the first one it encounters.
It seems that outlineView does not independently keep track of the parent item when loading data from the data source.
Presumably the only way to overcome this would be to create some sort of unique wrapper object, a struct maybe, at each node to hold the common object.
Anyone have any idea what methods NSOutlineView uses to find the parent of a given object?

From NSOutlineView Class Reference (emphasis mine):
An outline view has the following features:
A user can expand and collapse rows.
Each item in the outline view must be unique. In order for the collapsed state to remain consistent between reloads the item's pointer must remain the same and the item must maintain isEqual: sameness.

Related

Modifying Schema only for one document

I'm creating an application in the MERN stack and I stumbled upon a problem. I will start by explaining how that app is going to work.
So, in that application users can create their Collections. It can be anything - a collection of books, a collection of a favorite food - anything. Now in these Collections, they can create Items - for example, specific books.
We can navigate through the application to the different Collection Pages or the specific Item Pages in those Collections. You get the idea. There is a list of all the Collections on the main page and we can click e.g. Books Collection, then click on the Harry Potter item, and we will visit the Page for that specific book.
When a user creates an Item, he has to add a name and tag to it. But the user can set his own fields, like for example Author field for that Books Collection. Then every Item (book) will gain that Author field. It's obvious, that the main Item Schema is not affected by that additional field. Because we don't wanna the Author field in the Favourite Food Collection.
Anyway, I know how to modify data of already existing Items, but how to change that Schema for an Items that user gonna create in the future? Because if the user added Author field, we obviously want that field to show every time that user creates a new Item (book) in that certain Collection. Should I create a whole new Schema, only for the modified document? Or is there a different, more approachable way of achieving what I want right here?
As far as saving dynamic data in the collection, you could use Mixed Type or Object Type, see more info here
For keeping track of the fields the user has used previously, we could maintain a array within, having all the fields

Displaying multiple Child under Parent (Preference) in ReactJs

I want to achieve something related to this:
https://codesandbox.io/s/3vqyo8xlx5
But I want the child to appear under the preference of where the button of "Add Child" is clicked, not on the last one.
Please, I need help on this
Is this your code? Look the way it's designed, you're using one array to store parents and other to store it's children. Instead, why don't you create an array of objects in the state, then add a new object when you input preferences, add the preferences as values of each object, then just render them using array map (one for objects and one nested map to get the values of each parameter).

ADF tree binding issue

I'm using 3 levels tree VO's. All three VO's has bind variables. The VO's are connected via View link. I'm using createViewLinkAccessorRS in order to pass the variables from parent to child VO.. i defined Target Data Source (EL_expression) for second and third level.The tree works fine, and the nodes filled correctly (all the way down). The Problem is that the second and the third tree level attributes are only shown in the tree component. anywhere else in the page it looks like they are empty ({bindings.(attname).inputValue} = null) (E.g - after dragging the third tree level "FlowOrder" from the AppModuleDataControl and create a form out of it, and selecting the second node of the tree will update all the third level tree node (please see attached image), but will leave the entire form which was just created empty)
Any idea why the FlowOrder bindings are empty? i assume that maybe it has to do with the bind variable of the VO .. i even thought i would change the tree selection listener so on the second level click it will perform a full query of "FlowOrder" via executewithparams, but it does not make any sense because the data was fetched already after clicking level 2 tree)
(Jdeveloper : 12.2.1.2.0)
attached image: Details
Check out my explanation on trees and example application in another post: ADF filter table based on tree selection The tree shows data from view link accessors. The form shows data from view instance. They are in different state.

Load empty values from referenced node in Views (Drupal 7)

I have a view displaying nodes of two content types. The nodes all have a cck field made with Entity Reference referencing a "parent" node. If the displayed node in the view has an empty value, the view should display the value in the parent node. Simple as that.
The filters should also be able to filter on the parent's values...
I'm thinking it should be solved with handlers somehow, but I'm having a lot of trouble finding my way through the documentation. Could anybody please help?
I'm working with Drupal 7.14, Views 7.x-3.3 and Entity Reference 7.x-1.0-rc3+2-dev.
-- Mikkel

Backbone.js Approach to Managing UI State / Handling Selections in UI

My question deals with this UI sample.
Having trouble with approach to managing the "selected" state of various UI view components. For example, I have menus above from which the user makes various selections. These selections should cause updates in the menus themselves (HL selected items) and also cause updates in the results, which would be based on the selections made. Also, the menus have different kinds of rules. For example, you can only have one "list" selected at a time, but you can have multiple "tags" selected.
One approach that I was thinking about was to create a Backbone model that holds the state of the UI "selection". For example, I could have a model SearchCriteria that holds this information. Then, when a user makes choices in the UI, I could update this model. I could have the various view components listen for changes in this model (as well as changes in the primary data models.) Then, the views would update their visual state by updating which items are shown as selected.
One item I am struggling with in this approach is who should be responsible for updating the selected state of an item. For example, on the list of tags, I might have the following pieces defined...
Tag (model to represent a tag)
TagCollection (collection to represent a collection of tags)
TagMenuView (view that represents the menu of tags available to select)
TagMenuItemView (view that represents a single item in the menu)
Should I...
Set up an event listener on the TagMenuItemView for click, and then try to handle 1) updating the SearchCriteria model, and 2) updating the visual state of the menu, e.g. selected items?
Or, should I have the higher level view (the TagMenuView) listen for events such as the user selecting a tag, and perform the work there?
Also, the tags menu in this example allows multiple items to be selected, but the lists menu would only allow one list at a time to be selected. Where would this "UI" rule (or is this really a business rule related to a search?) be enforced? For example, if I listened for click events on each individual list menu item, I could certainly update the visual state of that item, but, I also need to make sure the higher level menu view deselects any other selected lists. So, would it be better to manage the "UI" state of something like the to-do list menu in the view that would represent that entire menu (a ToDoListMenuView) rather than on each individual menu item view?
Sorry for so many questions. I am just having a hard time moving to this model of development.
You're almost to an answer similar to the one I would use.
If you appreciate that list, search, due and tags are search filters on a big collection of to-dos, you are 90% of the way to enlightenment. In fact, other than search, all of those are just "kinds of tags"! (Unless you have 10,000 to-do items, there are no performance or memory-related reasons to have lists of lists of to-dos; "Work", "Project #1", and "Personal" are just specialized tags by which you filter items out of your view, showing only those related to one sphere of your life or another.)
Create the SearchCriteria model. (You are not technically searching, you're filtering: you're excluding from your view those things that don't match your search criteria.) This model will hold a lot of attributes about your client state. Your search criteria are almost entirely driven by data present in the client (since the search applies to only one ToDoList at a time), so it's entirely SearchCriteria related, not ToDo object related.
All Views bind to change/add/remove events on SearchCriteria. When the user clicks on any of the views (list, view, tag), that message is forwarded to SearchCriteria. It makes the appropriate internal changes, which in turn triggers the views to re-render themselves. One of the event recipients in the main ToDoListView, which during its render then checks the search criteria. Something like:
ToDoListView = Backbone.View.extend({
...
render: function() {
var self = this,
toDraw = this.collection.filter(
function(c) { return this.searchCriteria.passes(c); });
$(this.el).html('');
_.each(toDraw, function(c) {
(new ToDoItemView({model: c, parent: self})).render(); });
}
That may be a little personally idiomatic, passing in the parent object and letting the item insert itself into the parent's DOM object. You could pass in anything: the element to be appended to. Alternatively, render could return a DOM object and the ListView could do the appending. That's a matter of taste. I've done both.
You do have to dig a little into backbone's parent library, underscore, to grok the essential wonderfulness of the _.each() usage.
Also, I've often contained an entire Backbone application in a self-executing anonymous function, and leaving "searchCriteria" as a variable accessible to all objects within the scope of the SEAF, so it wouldn't be this.searchCriteria, but just searchCriteria.
You can also write SearchCriteria so it calls sync, writing event state to the server, which you can then save as a raw JSON object; the nice thing about sync is that if what you send and what you receive are the same, no events are triggered, so you don't get a double-render effect, and the nice thing about using JSON is that it's client-appropriate, but contains nothing that the server's ToDo relationships care about.
Furthermore, you can specify specific client-side behavior rules. Such as: when you change ToDo Lists, you can apply the text-search criteria, or, as an alternative, you can decide that changing lists clears the text-search criteria field; doing so will trigger an event that will cause the "TextSearchView" to clear its input box (you'll have to write that event handler, but it'll be obvious you meant to do that). You can make up any rule you like, such as "changing lists clears all selections," but that doesn't seem sensible. I can easily imagine trying to tackle the bugs in my "project" list and in my personal life. But clearing the search box just seemed more... sensible, if you know what I mean.

Resources