Drag and Drop: by using copyArrayItem() the dragged item should not be removed from start array while drop Angular 8 - angular-material

I have a list of items from where I drag an item and drop it into another list. I'm using copyArrayItem() method from Angular to not remove the item from the previous array.
I start dragging, the item is within the previous array: the placeholder from that item shows up.
Start dragging, placeholder shows up
I'm leaving the previous array: the placeholder/dragged item disappears (I want that the placeholder/dragged item stays) -> the start array has minus 1 items.
Placeholder disappears, what I don't want
I'm on the target array: a placeholder appears in a target array.
I'm dropping the item: item appears now in the start and target array.

After more research I've found an open issue about that problem:
https://github.com/angular/components/issues/13906
and there I've found suggestions from participants:
https://stackblitz.com/edit/angular-krmecd?file=src%2Fapp%2Fapp.component.ts
This example with workaround helped me to solve this problem:
https://stackblitz.com/edit/angular-o8exzv-jauhhi?file=src%2Fapp%2Fcdk-drag-drop-connected-sorting-example.html
Maybe this information will be useful for someone.

Related

How to remove a selected item on KeyDown event in PaperJS

First steps with PaperJS. I realized this sketch and this video to describe the issue. As you can see in the video, drawing, for example, three items, and moving over them to select one and pressing the "d" key on keybord, it is possible to remove just the last added and selected item, but not the previous ones. If you start from the first or second item of the three added, the alert is not even triggered.
The wanted beaviour would be instead to select the event.item.selected (moving on it with the mouse) and remove just the selected one by clicking the "d" key on keyboard.
Thank you for your help
Your issue is that after removing the first path, your path variable no longer points to nothing.
So the next time you hit the delete key, you no longer know the selected path.
What you should do instead is storing the currently selected path into another variable and use it instead.
Here's a corrected sketch based on your code, demonstrating this.

How to remove an item from a paper-listbox?

I can add an item to a paper-listbox with
Polymer.dom($['mylistbox']).append(paperItem);
However I'm having trouble deleting it from the list afterwards. I tried:
paperItem.remove();
That initially makes it dissapear, but it appears again after selecting another item in the list. How do I remove a paper-item from a listbox?
Polymer.dom($['mylistbox']).removeChild(paperItem);

How to create a Hierarchical menu in iOS?

In my application, I have a menu that is defined as follows. Each item on the menu is a node that has the following data attributes:
MenuText : (the text that would appear for that item)
isView : Whether this item is a leaf level item or not
subMenus : if isView is false, then there are multiple menu items under this attribute.
Thus, it is a tree structure that can go till any depth. The items in the menu can change periodically and hence the implementation has to be kept flexible. This data is stored in a plist file and read into an NSArray in the code (already implemented).
I now need to create a slide out menu on the left that will be populated by this data hierarchy. I have created the menu pane and added swipe gestures to it, all of which work fine. The menu has to be a collapsible one where clicking on one menu item expands the subViews below it. If the item clicked on is a view, then a new view is loaded on the rest of the screen with appropriate data.
The problem I am facing is the logic to populate the menu (which is a UITableView) from the NSArray data. The following are the two approaches I came up with.
Create a UITableView with as many sections as there are items at the top level of the menu. Then iterate through the menu items recursively. For each menu item that is not a view (i.e. it has subMenus), create a new section with number of rows equal to the number of subMenus under it. When I come across a menu item that is a view and has no further subMenus, add it as a row to the subsection created for the menu one level above it.
Create a menu with one section and as many rows as the number of menu items at the top level. When a menu item is clicked, insert rows under it to represent its sub-menus. When another menu item on the same level is clicked, collapse the previously expanded menu by deleting the inserted rows. When a menu item with no sub menus is clicked, the rest of the screen is populated with data.
I have tried both the approaches and not been able to go beyond the initial steps. For the first method, I understand that I need to add a UITableView as a part of UITableViewCells, which is good, but I need to do that recursively. For the second approach, I need to know the indexPath of each item clicked which can go to many levels.
I would like some suggestions here about which approach I should take and some guidance over how to go about it. Also, if there is any better way to do this, kindly advice. Thanks.
In my opinion, using UINavigationController is the easiest way. You can push as many UITableViews as you want.
If it doesn't fit your design requirement, you can try expandable UITableViews. There are few open sources:
JKExpandTableView
SDNestedTable
iOS-Tree-Component
Thanks for the responses. I ended up doing this using the following control:
Accordion for iOS
It has served my purpose beautifully and I posted it here so that someone with the same requirement may find it.
Take a look at TLIndexPathTools. It has a "Tree" extension that can do this. Try running the Outline sample project. The main task in adapting the sample project would be to write a recursive function to convert your array of nodes into an array of TLIndexPathTreeItem objects. All of the code in the controller:willChangeNode: method is examples of lazy loading and it doesn't sound like you'd need any of that.

tagcompletion like stackoverflow

Working example
Bug
add an item that exists in the list
add an item that doesn't exist in the list
add an item that exists in the list by clicking arrow key or clicking an item with mouse
notice that all items are erased and everything starts over.
I am building this on top of a solution provided to me in another question. I've taken the code from that example and modified to my needs. however, now I am having the issue stated above.
What can I do to avoid having the list erase all items when a new item is added by clicking down arrow key after a non existent item is added.
Add the following to the options object you pass the autocomplete widget:
focus: function() { return false; }
From the docs on focus:
Canceling this event prevents the
value from being updated, but does not
prevent the menu item from being
focused.
Here's your example without the bug: http://jsbin.com/oquda3/4

How do I move multiple nodes at once in a TJvTreeView?

When you select multiple nodes of a JvTreeView, and then try to drag these nodes, the JvTreeView selects the node you clicked to drag, rather than initiating dragging all the selected nodes. You end up dragging only this single node.
Is it possible to drag multiple nodes in a JvTreeView? I am using Delphi 2007.
UPDATE: Oddly enough, if I hold down CTRL+SHIFT when dragging the items, I can successfully drag them all. Any ideas?
Suppose MultiSelectStyle is the default [msControlSelect], then the answer to your question is 'you don't release the control key when you're selecting the last item and beginning dragging'.
The culprit is in TJvTreeView.WMLButtonDown in JvComCtrls.pas. Code there tests if 'Ctrl' is pressed when the TreeView is MultiSelect, and clears all items and selects the clicked item if 'Ctrl' is not pressed. It should instead test if the clicked item is already selected and do nothing if it is.
You can see the broken behavior without dragging. Multi select a few items and then click a selected item with the mouse. The VCL TreeView do not select or de-select anything, while the JVTreeView, instead, de-selects all items and selects the clicked one.
Yes absolutely, I do it all the time.
Of course Multi-Select needs to be True and you may need to have a look at the TTreeView's MultiSelectStyle. That controls what type of nodes can be selected at the same time. For example if msSiblingOnly is set to true, you can only select sibblings.
Are you using dmAutomatic or dmManual. If the latter, it could be that you are doing something in the OnMouse* events that is negating the multi-selection you made earlier.

Resources