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

UX enhancements #177

Merged
merged 2 commits into from
Oct 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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