Skip to content
This repository has been archived by the owner on Dec 10, 2019. It is now read-only.

Commit

Permalink
Merge pull request #177 from bobtherobot/master
Browse files Browse the repository at this point in the history
UX enhancements
  • Loading branch information
jccguimaraes authored Oct 28, 2017
2 parents eacad39 + 5d0f0e7 commit ac2ae06
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 10 deletions.
16 changes: 12 additions & 4 deletions src/editor-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,12 @@ 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;
// @commit: mike: Read "amNew" flag and don't render DELETE button.
if (! context.candidate.amNew){
actionsBlock.appendChild(deleteButton);
context.refs['pv-button-delete'] = deleteButton;
}

}
actionsBlock.appendChild(successButton);

Expand Down Expand Up @@ -418,7 +422,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;
// @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;
}

}

const listItem = document.createElement('li');
Expand Down Expand Up @@ -743,12 +751,12 @@ const initialize = function _initialize (model, candidate) {

actionsContainer.call(this, panelHeading);
typeContainer.call(this, panelBody);
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);
colorContainer.call(this, panelBody);
optionsContainer.call(this, panelBody);
pathsContainer.call(this, panelBody);
configContainer.call(this, panelBody);
groupsContainer.call(this, panelBody);

Expand Down
42 changes: 36 additions & 6 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,19 +274,19 @@ 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);
return !model || (model && model.type === 'group');
}
},
{
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);
Expand Down Expand Up @@ -626,12 +626,42 @@ const createNewProject = function _createNewProject (evt) {
const model = getModel(evt.target) || Object.prototype;
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;
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"

const newModel = {
type: 'project',
name: ''
name: name,
paths : tpathArray,
amNew : true // @commit: mike: a flag so we can hide the DELETE button.
};


Object.setPrototypeOf(newModel, model);
view.openEditor(null, newModel);

// @commit: mike: not sure why we can't just populate with some default
// view.openEditor(null, newModel);

view.openEditor(newModel, newModel);


};

const focusPanel = function _focusPanel () {
Expand Down

0 comments on commit ac2ae06

Please sign in to comment.