From 79cd8b481be80061d2c19297a04346c7e0589f2c Mon Sep 17 00:00:00 2001 From: mike gieson Date: Thu, 26 Oct 2017 02:45:13 -0400 Subject: [PATCH 1/2] Some UX enhancements to make adding a project faster / easier. A little hacky, but works better for me. --- src/editor-view.js | 17 +++++++++++++---- src/main.js | 43 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/src/editor-view.js b/src/editor-view.js index db3e6e4..3a442b1 100644 --- a/src/editor-view.js +++ b/src/editor-view.js @@ -120,8 +120,13 @@ const actionsContainer = function _actionsContainer (parentView) { actionsBlock.appendChild(cancelButton); if (context.model && (context.candidate && context.candidate.type)) { - actionsBlock.appendChild(deleteButton); - context.refs['pv-button-delete'] = deleteButton; + // mike + console.log("context", context); + if (! context.candidate.amNew){ + actionsBlock.appendChild(deleteButton); + context.refs['pv-button-delete'] = deleteButton; + } + } actionsBlock.appendChild(successButton); @@ -418,7 +423,11 @@ const addPath = function _addPath (context, parentView, path) { if (context.refs['pv-list-paths'].length === 1 && !getName(context)) { const name = nodePath.basename(context.refs['pv-list-paths'][0]); - context.refs['pv-input-name'].value = name; + // mike + if(context.refs['pv-input-name']){ + context.refs['pv-input-name'].value = name; + } + } const listItem = document.createElement('li'); @@ -743,12 +752,12 @@ const initialize = function _initialize (model, candidate) { actionsContainer.call(this, panelHeading); typeContainer.call(this, panelBody); + pathsContainer.call(this, panelBody); //put right up top... all the other stuff is candy. nameContainer.call(this, panelBody); sortByContainer.call(this, panelBody); iconContainer.call(this, panelBody); colorContainer.call(this, panelBody); optionsContainer.call(this, panelBody); - pathsContainer.call(this, panelBody); configContainer.call(this, panelBody); groupsContainer.call(this, panelBody); diff --git a/src/main.js b/src/main.js index 3775174..fdcdd30 100644 --- a/src/main.js +++ b/src/main.js @@ -274,9 +274,9 @@ const commandscontextMenu = function _commandscontextMenu () { } }, { - command: 'project-viewer:createNewGroup', + command: 'project-viewer:createNewProject', created: function (evt) { - this.label = `Create new group...`; + this.label = `New Project...`; }, shouldDisplay: function (evt) { const model = getModel(evt.target); @@ -284,9 +284,9 @@ const commandscontextMenu = function _commandscontextMenu () { } }, { - command: 'project-viewer:createNewProject', + command: 'project-viewer:createNewGroup', created: function (evt) { - this.label = `Create new project...`; + this.label = `New Group...`; }, shouldDisplay: function (evt) { const model = getModel(evt.target); @@ -626,12 +626,43 @@ const createNewProject = function _createNewProject (evt) { const model = getModel(evt.target) || Object.prototype; const view = map.get(this); if (!view) { return; } + + var dirs = atom.project.getDirectories(); + var name; + var tpathArray; + if(dirs && dirs.length){ + // path.parse().name doesn't return proper name if folder has dots (e.g. folder named "foo.bar" yeilds "foo") + var tpath = dirs[0].path; + var Apath = tpath.split(path.sep); + name = Apath.pop() || ''; + // maybe trailing slash + if( ! name ) { + name = Apath.pop() || ''; + } + + tpathArray = [tpath]; + } + + name = name || "Yoda" + +console.log("tpathArray", tpathArray); + const newModel = { type: 'project', - name: '' + name: name, + paths : tpathArray, + amNew : true }; + Object.setPrototypeOf(newModel, model); - view.openEditor(null, newModel); +// mike +console.log("newModel.name", newModel.name) + // hack into model. + //newModel.name = name; + //model.name = name; + view.openEditor(newModel, newModel); + + }; const focusPanel = function _focusPanel () { From 5d0f0e7c10c5c4f31368488a0bb93e1b41e8321a Mon Sep 17 00:00:00 2001 From: mike gieson Date: Thu, 26 Oct 2017 02:53:51 -0400 Subject: [PATCH 2/2] Added some UX enhancements to make setting up a project faster. --- src/editor-view.js | 7 +++---- src/main.js | 15 +++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/editor-view.js b/src/editor-view.js index 3a442b1..aa059ce 100644 --- a/src/editor-view.js +++ b/src/editor-view.js @@ -120,8 +120,7 @@ const actionsContainer = function _actionsContainer (parentView) { actionsBlock.appendChild(cancelButton); if (context.model && (context.candidate && context.candidate.type)) { - // mike - console.log("context", context); + // @commit: mike: Read "amNew" flag and don't render DELETE button. if (! context.candidate.amNew){ actionsBlock.appendChild(deleteButton); context.refs['pv-button-delete'] = deleteButton; @@ -423,7 +422,7 @@ const addPath = function _addPath (context, parentView, path) { if (context.refs['pv-list-paths'].length === 1 && !getName(context)) { const name = nodePath.basename(context.refs['pv-list-paths'][0]); - // mike + // @commit: mike: This chokes when we fill a path... lets just validate before setting. if(context.refs['pv-input-name']){ context.refs['pv-input-name'].value = name; } @@ -752,7 +751,7 @@ const initialize = function _initialize (model, candidate) { actionsContainer.call(this, panelHeading); typeContainer.call(this, panelBody); - pathsContainer.call(this, panelBody); //put right up top... all the other stuff is candy. + pathsContainer.call(this, panelBody); // @commit: mike: Put path and name up top... all the other stuff is candy. nameContainer.call(this, panelBody); sortByContainer.call(this, panelBody); iconContainer.call(this, panelBody); diff --git a/src/main.js b/src/main.js index fdcdd30..f3387ea 100644 --- a/src/main.js +++ b/src/main.js @@ -627,6 +627,7 @@ const createNewProject = function _createNewProject (evt) { const view = map.get(this); if (!view) { return; } + // @commit: mike: Auto populate the new project name and first open folder. var dirs = atom.project.getDirectories(); var name; var tpathArray; @@ -645,21 +646,19 @@ const createNewProject = function _createNewProject (evt) { name = name || "Yoda" -console.log("tpathArray", tpathArray); - const newModel = { type: 'project', name: name, paths : tpathArray, - amNew : true + amNew : true // @commit: mike: a flag so we can hide the DELETE button. }; + Object.setPrototypeOf(newModel, model); -// mike -console.log("newModel.name", newModel.name) - // hack into model. - //newModel.name = name; - //model.name = name; + + // @commit: mike: not sure why we can't just populate with some default + // view.openEditor(null, newModel); + view.openEditor(newModel, newModel);