diff options
Diffstat (limited to 'js/io/workflow/newFileDialog/new-file-options-navigator.reel/new-file-options-navigator.js')
-rwxr-xr-x[-rw-r--r--] | js/io/workflow/newFileDialog/new-file-options-navigator.reel/new-file-options-navigator.js | 375 |
1 files changed, 312 insertions, 63 deletions
diff --git a/js/io/workflow/newFileDialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/workflow/newFileDialog/new-file-options-navigator.reel/new-file-options-navigator.js index 86c2c86b..61b963b3 100644..100755 --- a/js/io/workflow/newFileDialog/new-file-options-navigator.reel/new-file-options-navigator.js +++ b/js/io/workflow/newFileDialog/new-file-options-navigator.reel/new-file-options-navigator.js | |||
@@ -8,8 +8,8 @@ var Montage = require("montage/core/core").Montage, | |||
8 | Component = require("montage/ui/component").Component, | 8 | Component = require("montage/ui/component").Component, |
9 | iconsListModule = require("js/components/ui/icon-list-basic/iconsList.reel"), | 9 | iconsListModule = require("js/components/ui/icon-list-basic/iconsList.reel"), |
10 | treeModule = require("js/components/ui/tree-basic/tree.reel"), | 10 | treeModule = require("js/components/ui/tree-basic/tree.reel"), |
11 | newFileLocationSelectionModule = require("js/io/workflow/newFileDialog/new-file-workflow-controller"); | 11 | newFileLocationSelectionModule = require("js/io/workflow/newFileDialog/new-file-workflow-controller"), |
12 | newFileWorkflowControllerModule = require("js/io/workflow/newFileDialog/new-file-location.reel"); | 12 | fileSystem = require("js/io/system/filesystem").FileSystem; |
13 | 13 | ||
14 | var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(Component, { | 14 | var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(Component, { |
15 | 15 | ||
@@ -23,10 +23,30 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C | |||
23 | enumerable:false, | 23 | enumerable:false, |
24 | value:null | 24 | value:null |
25 | }, | 25 | }, |
26 | selectedTemplates:{ | 26 | selectedTemplate:{ |
27 | writable: true, | 27 | writable: true, |
28 | enumerable:false, | 28 | enumerable:false, |
29 | value:[] | 29 | value:null |
30 | }, | ||
31 | newFileName:{ | ||
32 | writable:true, | ||
33 | enumerable:false, | ||
34 | value:"" | ||
35 | }, | ||
36 | newFileDirectory:{ | ||
37 | writable:true, | ||
38 | enumerable:false, | ||
39 | value:"" | ||
40 | }, | ||
41 | templateWidth:{ | ||
42 | writable:true, | ||
43 | enumerable:false, | ||
44 | value:"0 px" | ||
45 | }, | ||
46 | templateHeight:{ | ||
47 | writable:true, | ||
48 | enumerable:false, | ||
49 | value:"0 px" | ||
30 | }, | 50 | }, |
31 | willDraw: { | 51 | willDraw: { |
32 | enumerable: false, | 52 | enumerable: false, |
@@ -46,20 +66,32 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C | |||
46 | //draw left nav project type tree | 66 | //draw left nav project type tree |
47 | var tree = treeModule.Tree.create(); | 67 | var tree = treeModule.Tree.create(); |
48 | tree.showIcons = false; | 68 | tree.showIcons = false; |
69 | tree.expandTreeAfterDraw = true; | ||
49 | tree.directoryBold = true; | 70 | tree.directoryBold = true; |
50 | tree.treeViewDataObject = this.newFileModel.prepareContents("projectTypes"); | 71 | tree.highlightedUri = this.newFileModel.defaultProjectType; |
72 | tree.treeViewDataObject = this.newFileModel.prepareContents("categories"); | ||
51 | tree.element = this.projectTypeTree; | 73 | tree.element = this.projectTypeTree; |
52 | tree.needsDraw = true; | 74 | tree.needsDraw = true; |
53 | 75 | ||
54 | var newFileLocation = newFileWorkflowControllerModule.NewFileLocation.create(); | 76 | //highlight defaultProjectType |
55 | newFileLocation.element = this.locationSelection; | ||
56 | newFileLocation.needsDraw = true; | ||
57 | 77 | ||
58 | this.addIdentifiers(); | 78 | this.addIdentifiers(); |
59 | 79 | ||
60 | this.element.addEventListener("drawTree", function(evt){that.handleNewFileNavDrawTree(evt);}, false); | 80 | this.element.addEventListener("drawTree", function(evt){that.handleNewFileNavDrawTree(evt);}, false); |
61 | this.element.addEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only | 81 | this.element.addEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only |
62 | this.cancelButton.addEventListener("click", this, false); | 82 | this.eventManager.addEventListener("newFileDirectorySet", function(evt){that.handleNewFileDirectorySet(evt);}, false); |
83 | this.eventManager.addEventListener("newFileNameSet", function(evt){that.handleNewFileNameSet(evt);}, false); | ||
84 | |||
85 | if(!!this.newFileModel.defaultProjectType){ | ||
86 | var templates = this.newFileModel.prepareContents(this.newFileModel.defaultProjectType); | ||
87 | this.templateList = iconsListModule.IconsList.create(); | ||
88 | this.templateList.iconsViewDataObject = templates; | ||
89 | this.templateList.element = this.templateIcons; | ||
90 | this.templateList.needsDraw = true; | ||
91 | |||
92 | |||
93 | this.selectedProjectType = {"uri":this.newFileModel.defaultProjectType, "element":null}; | ||
94 | } | ||
63 | } | 95 | } |
64 | 96 | ||
65 | }, | 97 | }, |
@@ -71,61 +103,72 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C | |||
71 | addIdentifiers:{ | 103 | addIdentifiers:{ |
72 | value: function(){ | 104 | value: function(){ |
73 | this.element.identifier = "newFileNav"; | 105 | this.element.identifier = "newFileNav"; |
74 | this.okButton.identifier = "okButton"; | ||
75 | this.cancelButton.identifier = "cancelButton"; | ||
76 | } | 106 | } |
77 | }, | 107 | }, |
78 | 108 | ||
79 | handleNewFileNavDrawTree:{ | 109 | handleNewFileNavDrawTree:{ |
80 | value: function(evt){ | 110 | value: function(evt){ |
81 | //toggle open or close for directory | 111 | //toggle open or close for directory |
82 | if((evt.uriType === "directory") && (!!evt.subTreeContainer)){ | 112 | if((evt.uriType === "directory") && (!!evt.subTreeContainer)){ |
83 | var tree = treeModule.Tree.create(); | 113 | var tree = treeModule.Tree.create(); |
84 | tree.showIcons = false; | 114 | tree.showIcons = false; |
85 | tree.treeViewDataObject = this.newFileModel.prepareContents(evt.uri); | 115 | tree.highlightedUri = this.newFileModel.defaultProjectType; |
86 | tree.element = evt.subTreeContainer; | 116 | tree.treeViewDataObject = this.newFileModel.prepareContents(evt.uri); |
87 | tree.needsDraw = true; | 117 | tree.element = evt.subTreeContainer; |
88 | } | 118 | tree.needsDraw = true; |
89 | } | 119 | } |
90 | }, | 120 | } |
121 | }, | ||
91 | 122 | ||
92 | handleNewFileNavSelectedItem:{ | 123 | handleNewFileNavSelectedItem:{ |
93 | value: function(evt){ | 124 | value: function(evt){ |
94 | var selectionType = this.newFileModel.projectTypeData[evt.uri].type; | 125 | var selectionType = this.newFileModel.projectTypeData[evt.uri].type; |
95 | if(evt.target.classList.contains("atreeItemContent") && (selectionType === "file")){//populate templates for project type selection | 126 | if(evt.target.classList.contains("atreeItemContent") && (selectionType === "file")){//populate templates for project type selection |
96 | //save project type selection | 127 | this.highlightSelection(evt.target, "projectType", evt.uri); |
97 | this.selectedProjectType = evt.uri; | 128 | |
98 | 129 | //clear current template selection | |
99 | //render templates | 130 | if((!!this.selectedTemplate) && (this.selectedTemplate.element.classList.contains("selected"))){ |
100 | var templates = this.newFileModel.prepareContents(evt.uri); | 131 | this.selectedTemplate.element.classList.remove("selected"); |
101 | if(this.templatesContainer.querySelectorAll(".list").length > 0){ | ||
102 | this.templateList.iconsViewDataObject = templates; | ||
103 | }else{ | ||
104 | this.templateList = iconsListModule.IconsList.create(); | ||
105 | this.templateList.iconsViewDataObject = templates; | ||
106 | this.templateList.element = this.templateIcons; | ||
107 | this.templateList.needsDraw = true; | ||
108 | } | ||
109 | } | 132 | } |
110 | 133 | ||
111 | if(evt.target.classList.contains("icon")){ | 134 | //disable ok |
112 | //save template selection | 135 | if(!this.okButton.hasAttribute("disabled")){ |
113 | this.selectedTemplates.push[evt.uri];//todo: check for duplicates | 136 | this.okButton.setAttribute("disabled", "true"); |
137 | } | ||
138 | |||
139 | //save project type selection | ||
140 | this.selectedProjectType = {"uri":evt.uri, "element":evt.target}; | ||
114 | 141 | ||
142 | //render templates | ||
143 | var templates = this.newFileModel.prepareContents(evt.uri); | ||
144 | if(this.templatesContainer.querySelectorAll(".list").length > 0){ | ||
145 | this.templateList.iconsViewDataObject = templates; | ||
146 | }else{ | ||
147 | this.templateList = iconsListModule.IconsList.create(); | ||
148 | this.templateList.iconsViewDataObject = templates; | ||
149 | this.templateList.element = this.templateIcons; | ||
150 | this.templateList.needsDraw = true; | ||