Flex selectedItem sort order - actionscript-3

I have a code as following
var selectedWindows = new ShowSelectedFilesFolderWindow;
selectedWindows.setParentData(MainFileGrid.selectedItems);
The problem is that when I retrieved the list from the dialog, the list(hierarchical data) was sorted according to the way the selection was made in the main window. For example, if I selected bottom-up,it displayed folder first, if I selected up-to-bottom, it displayed file first.
How can I keep the default folder first display ?

I got it solved as the following
public function setParentData(obj:Object):void{
var tempArr:Array = obj as Array;
if(tempArr[0].Type == "file"){
this.parentData = tempArr.reverse();
}else{
this.parentData = tempArr;
}
}

Related

How to select all in primefaces dataTable with liveScroll

I'm using primefaces v5.3 dataTable with liveScroll="true" and selectionMode="multiple".
Header checkbox selects only visible rows and when i scroll down new rows appear non selected.
I want header checkbox to select all rows: visible and invisible.
Selection of only visible rows is meaningless and useless.
Is it possible to fix?
I tried to add all table data to selection by processing "toggleSelect, rowSelectCheckbox and rowUnselectCheckbox" events. It works on backend, but in UI rows are unselected anyway.
Use this script to replace the original updateData function of primefaces
PrimeFaces.widget.DataTable.prototype.updateData = (function() {
var cached_function = PrimeFaces.widget.DataTable.prototype.updateData;
return function() {
var reselectAll = (this.selection != undefined && (this.selection[0] === '#all' || this.selection.length === this.getTbody()[0].getElementsByTagName('tr').length);
var result = cached_function.apply(this, arguments);
if (reselectAll) {
this.selectAllRows();
}
return result;
};
})();
that will automatically select the new loaded rows on the table(only the ones that are visible on the client side)

How to make a closed search in Google Docs?

I have a document where I need to find a text or word, each time i run a function the selection has to go to next if a word or text is found. If it is at the end it should take me to top in a circular way just like find option in notepad.
Is there a way to do it?
I know about findText(searchPattern, from) but I do not understand how to use it.
There are several wrappers and classes in the DocumentApp. They help to work with the contents of the file.
Class Range
Class RangeElement
Class RangeBuilder
It is necessary to understand carefully what they are responsible. In your case the code below should be work fine:
function myFunctionDoc() {
// sets the search pattern
var searchPattern = '29';
// works with current document
var document = DocumentApp.getActiveDocument();
// detects selection
var selection = document.getSelection();
if (!selection) {
if (!document.getCursor()) return;
selection = document.setSelection(document.newRange().addElement(document.getCursor().getElement()).build()).getSelection();
}
selection = selection.getRangeElements()[0];
// searches
var currentDocument = findNext(document, searchPattern, selection, function(rangeElement) {
// This is the callback body
var doc = this;
var rangeBuilder = doc.newRange();
if (rangeElement) {
rangeBuilder.addElement(rangeElement.getElement());
} else {
rangeBuilder.addElement(doc.getBody().asText(), 0, 0);
}
return doc.setSelection(rangeBuilder.build());
}.bind(document));
}
// the search engine is implemented on body.findText
function findNext(document, searchPattern, from, callback) {
var body = document.getBody();
var rangeElement = body.findText(searchPattern, from);
return callback(rangeElement);
}
It looks for the pattern. If body.findText returns undefined then it sets on top of the document.
I have a gist about the subject https://gist.github.com/oshliaer/d468759b3587cfb424348fa722765187

List of elements gets overridden in angular js when using in dropdown

I want to show a hierarchy like in the image. I am able to create this hierarchy and I want to show the second level elements in a dropdown. However, while doing this the hierarchy value gets overrided with dropdown value and hence I am not able to show the third level of hierarchy.
This is my Dropdown html page:
Business Domain
OK
This is my controller:
controller('domainController', ['$scope', '$state', 'DomainNameService', function($scope, $state, DomainNameService) {
$scope.busdomain = DomainNameService.getBusDomainName();
/*For populating the domain values Which I am fetching from service
Attached the json image*/
var domainList=DomainNameService.getBusDomainName();
if(domainList!=null){
domainList[0].childNode.sort();
for (var i = 0; i < domainList[0].childNode.length; i++) {
if (domainList[0].childNode[i].name!=null) {
var name=domainList[0].childNode[i].name;
domainList[0].childNode.splice(i,1,name);//for replacing the object with name as I have to show name in dropdown list
$scope.busdomainname=domainList[0].childNode;//got the list of name but after this my service list also get overrides
$scope.busdomainname.sort();
break;
}
else
{
$scope.busdomainname=$scope.busdomain[0].childNode;//Added for getting business domain list
$scope.busdomainname.sort();
}
}
}
$scope.addSubDomainTree = function(val){
var varType = "busSubDomain";
var domain=[];
var busDomain=$scope.bussubdomain;
var parent = DomainNameService.getDomainName()[0];
//Done some code here to get the hierarchy
DomainNameService.setBusDomain($scope.statements);
$scope.domain.domainName = DomainNameService.getBusDomainName[0];
$state.go('BusDomainTree', null, { reload: true });//fix for refresh issue.
}
}
}
This is my Service Method
setChildBD: function(varType,childBD,value,val){
if(varType == "busSubDomain"){
this.error=undefined;
if(childSubDomainName.indexOf(childBD)==-1){
childSubDomainName.push(childBD);
var i= childDomainName.indexOf(val);
//Done this for replacing the object name with an array which contains the child.attached the image for its value
childDomainName.splice(i,1,value.childNode[0]);
}
},
getBusDomainName: function(){
return this.busDomainValue;//here the busDomainValue gets overrided with the controller list value
},
Can anyone please suggest how to resolve this issue?
Got a solution for this. I used var domainList=angular.copy($scope.busdomain) instead of var domainList=DomainNameService.getBusDomainName(); in controller.js –

How do you get a selection from a DocsListDialogue?

I have a docs List dialogue, here is my code so far. How do I get the actual selection from the DocListDialogue though? I keep tried eventInfo.parameter,but that only returned a generic object and I need a file to be returned. Here is my code:
function init() {
var app = UiApp.createApplication().setTitle("WriteWell");
var selectionHandler = app.createServerHandler("selectHandler");
app.createDocsListDialog().showDocsPicker().setDialogTitle("Select File to Open").addSelectionHandler(selectionHandler);
app.add(app.createVerticalPanel().setId("Panel"));
return app;
}
function doGet(e) {
return init();
}
function selectHandler(eventInfo){
var parameter = eventInfo.parameter;//Selection???
var app = UiApp.getActiveApplication();
var panel = app.getElementById("Panel");
panel.add(app.createLabel(parameter.getId()));//Returns an error
}
When inspecting the content of eventInfo.parameter, we see that returns something like this:
{
source=u01234567890,
items=[
{
id=0Abcd-efgH_ijKLLLmnOPQr0stuvwX,
name=file_name,
url=https://docs.google.com/file/d/0Abcd-efgH_ijKLLLmnOPQr0stuvwX/edit?usp=drive_web
}
],
u01234567890=[
{
id=0Abcd-efgH_ijKLLLmnOPQr0stuvwX,
name=file_name,
url=https://docs.google.com/file/d/0Abcd-efgH_ijKLLLmnOPQr0stuvwX/edit?usp=drive_web
}
],
eventType=selection
}
If you need the ID of the selected file, you'll need something like:
...
eventInfo.parameter.items[0].id;
...
If you want to see what is in the eventInfo you can use
Logger.log(Utilities.jsonStringify(eventInfo));
which in this case would return something like that :
[13-10-13 21:25:21:722 CEST] {"parameter":{"source":"u16052058908","items":[{"id":"0AnZ5_ShBzI6pdHd4SWo0bUJYOEp4VFE4cDI1SUFvZFE","name":"Tracker locaux","url":"https://docs.google.com/a/insas.be/spreadsheet/ccc?key\u003d0AnZ5_ShBzI6pdHd4SWo0bUJYOEp4VFE4cDI1SUFvZFE\u0026usp\u003ddrive_web"}],"eventType":"selection","u16052058908":[{"id":"0AnZ5_ShBzI6pdHd4SWo0bUJYOEp4VFE4cDI1SUFvZFE","name":"Tracker locaux","url":"https://docs.google.com/a/insas.be/spreadsheet/ccc?key\u003d0AnZ5_ShBzI6pdHd4SWo0bUJYOEp4VFE4cDI1SUFvZFE\u0026usp\u003ddrive_web"}]}}
Looking at it you'll see that you can get the object properties you want using (for example) :
var docsInfo = eventInfo.parameter.items;
that will return an array of objects (one for each selected file) that contains file names, IDs and urls
Just iterate this objects array to get what you want from each item.

google script unable to update web page

Below is snippet where I create a web page / app and show a list. Then on click of item in list I want to replace the list with another list. I try it by using vertical panel as root container and clearing and adding list to it. The web page though keeps showing old list even after handler for new list executes fine.
//user_list function updates vertical panel but the web page still shows old rep_list
function doGet(e) {
if(e == null || e.parameter.dvid == null) {
return rep_list();
}
}
function user_list(path) {
var app = UiApp.getActiveApplication().setTitle("List Folders");
var content = app.getElementById('root');
content.clear();
var list = app.createListBox();
//populate list
content.add(list);
return app;
}
function rep_list () {
var app = UiApp.createApplication().setTitle("List Repositories");
var content = app.createVerticalPanel().setId('root');
var list = app.createListBox(true).setId('repoList').setName('repo');
var handler = app.createServerHandler("listFolders");
list.addClickHandler(handler)
//populate list
content.add(list);
app.add(content);
return app;
}
function listFolders(e){
var repo = e.parameter.repo;
user_list(repo);
}
Regards,
Miten.
Your listFolders() function isn't returning a new UI instance. Try:
function listFolders(e){
var repo = e.parameter.repo;
var app = user_list(repo);
return app;
}