Skip to content

Commit a5c9934

Browse files
committed
allow adding multiple urls via drag-and-drop in new task page (#136)
1 parent a010003 commit a5c9934

3 files changed

Lines changed: 27 additions & 4 deletions

File tree

app/scripts/controllers/new.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,29 @@
168168
var openUrlViaElectron = function (event, result) {
169169
$scope.$apply(function () {
170170
$scope.context.taskType = 'urls';
171-
$scope.context.urls = result.text;
171+
172+
if (result.append && $scope.context.urls && $scope.context.urls.trim() !== '') {
173+
var urls = $scope.context.urls.split('\n');
174+
var alreadyExists = false;
175+
176+
for (var i = 0; i < urls.length; i++) {
177+
if (urls[i] === result.text) {
178+
alreadyExists = true;
179+
break;
180+
}
181+
}
182+
183+
if (!alreadyExists) {
184+
if ($scope.context.urls.charAt($scope.context.urls.length - 1) !== '\n') {
185+
$scope.context.urls += '\n';
186+
}
187+
188+
$scope.context.urls += result.text;
189+
}
190+
} else {
191+
$scope.context.urls = result.text;
192+
}
193+
172194
$scope.context.uploadFile = null;
173195
$scope.context.newTaskInfo = null;
174196
$scope.context.collapseTrackers = true;

main/ipc/render-proecss.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ let notifyRenderProcessNewTaskFromFile = function (filePath, async) {
8787
core.mainWindow.webContents.send('on-main-new-task-from-file', result);
8888
};
8989

90-
let notifyRenderProcessNewTaskFromText = function (text, async) {
90+
let notifyRenderProcessNewTaskFromText = function (text, append, async) {
9191
let result = {
9292
text: text,
93+
append: !!append,
9394
async: !!async
9495
};
9596

@@ -112,7 +113,7 @@ let notifyRenderProcessNewNewTaskFromTextAfterViewLoaded = function (text) {
112113
}
113114

114115
ipcMain.once('on-render-view-content-loaded', (event, arg) => {
115-
notifyRenderProcessNewTaskFromText(text, true);
116+
notifyRenderProcessNewTaskFromText(text, false, true);
116117
});
117118
};
118119

main/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ let main = function () {
343343
let location = arg.location;
344344

345345
if (location.indexOf('/new') === 0) {
346-
ipcRender.notifyRenderProcessNewTaskFromText(text);
346+
ipcRender.notifyRenderProcessNewTaskFromText(text, true);
347347
} else {
348348
ipcRender.notifyRenderProcessNewNewTaskFromTextAfterViewLoaded(text);
349349
ipcRender.notifyRenderProcessNavigateToNewTask();

0 commit comments

Comments
 (0)