|
@@ -31,6 +31,7 @@
|
|
|
* @param {AssistHelper} options.assistHelper
|
|
* @param {AssistHelper} options.assistHelper
|
|
|
* @param {Object} options.definition
|
|
* @param {Object} options.definition
|
|
|
* @param {Function} options.activeEntry - The observable keeping track of the current open directory
|
|
* @param {Function} options.activeEntry - The observable keeping track of the current open directory
|
|
|
|
|
+ * @param {Function} options.trashEntry - The observable keeping track of the trash directory
|
|
|
* @param {HueFolder} options.parent
|
|
* @param {HueFolder} options.parent
|
|
|
* @param {string} options.app - Currently only 'documents' is supported
|
|
* @param {string} options.app - Currently only 'documents' is supported
|
|
|
*
|
|
*
|
|
@@ -39,6 +40,7 @@
|
|
|
function HueFileEntry (options) {
|
|
function HueFileEntry (options) {
|
|
|
var self = this;
|
|
var self = this;
|
|
|
self.activeEntry = options.activeEntry;
|
|
self.activeEntry = options.activeEntry;
|
|
|
|
|
+ self.trashEntry = options.trashEntry;
|
|
|
self.parent = options.parent;
|
|
self.parent = options.parent;
|
|
|
self.definition = ko.observable(options.definition);
|
|
self.definition = ko.observable(options.definition);
|
|
|
self.assistHelper = options.assistHelper;
|
|
self.assistHelper = options.assistHelper;
|
|
@@ -46,6 +48,10 @@
|
|
|
|
|
|
|
|
self.document = ko.observable();
|
|
self.document = ko.observable();
|
|
|
|
|
|
|
|
|
|
+ self.isTrash = ko.pureComputed(function () {
|
|
|
|
|
+ return self.definition().name === '.Trash';
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
self.isRoot = ko.pureComputed(function () {
|
|
self.isRoot = ko.pureComputed(function () {
|
|
|
return self.definition().name === '';
|
|
return self.definition().name === '';
|
|
|
});
|
|
});
|
|
@@ -178,6 +184,7 @@
|
|
|
|
|
|
|
|
var resultEntry = new HueFileEntry({
|
|
var resultEntry = new HueFileEntry({
|
|
|
activeEntry: self.activeEntry,
|
|
activeEntry: self.activeEntry,
|
|
|
|
|
+ trashEntry: self.trashEntry,
|
|
|
assistHelper: self.assistHelper,
|
|
assistHelper: self.assistHelper,
|
|
|
definition: {
|
|
definition: {
|
|
|
isSearchResult: true,
|
|
isSearchResult: true,
|
|
@@ -196,15 +203,23 @@
|
|
|
query: query,
|
|
query: query,
|
|
|
successCallback: function (data) {
|
|
successCallback: function (data) {
|
|
|
resultEntry.hasErrors(false);
|
|
resultEntry.hasErrors(false);
|
|
|
- resultEntry.entries($.map(data.children, function (definition) {
|
|
|
|
|
- return new HueFileEntry({
|
|
|
|
|
|
|
+ var newEntries = [];
|
|
|
|
|
+
|
|
|
|
|
+ $.each(data.children, function (idx, definition) {
|
|
|
|
|
+ var entry = new HueFileEntry({
|
|
|
activeEntry: self.activeEntry,
|
|
activeEntry: self.activeEntry,
|
|
|
|
|
+ trashEntry: self.trashEntry,
|
|
|
assistHelper: self.assistHelper,
|
|
assistHelper: self.assistHelper,
|
|
|
definition: definition,
|
|
definition: definition,
|
|
|
app: self.app,
|
|
app: self.app,
|
|
|
parent: self
|
|
parent: self
|
|
|
- })
|
|
|
|
|
- }));
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ if (!entry.isTrash()) {
|
|
|
|
|
+ newEntries.push(entry);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ resultEntry.entries(entries);
|
|
|
resultEntry.loading(false);
|
|
resultEntry.loading(false);
|
|
|
resultEntry.loaded(true);
|
|
resultEntry.loaded(true);
|
|
|
},
|
|
},
|
|
@@ -254,15 +269,22 @@
|
|
|
successCallback: function(data) {
|
|
successCallback: function(data) {
|
|
|
self.definition(data.document);
|
|
self.definition(data.document);
|
|
|
self.hasErrors(false);
|
|
self.hasErrors(false);
|
|
|
|
|
+ var newEntries = [];
|
|
|
|
|
|
|
|
- var newEntries = $.map(data.children, function (definition) {
|
|
|
|
|
- return new HueFileEntry({
|
|
|
|
|
|
|
+ $.each(data.children, function (idx, definition) {
|
|
|
|
|
+ var entry = new HueFileEntry({
|
|
|
activeEntry: self.activeEntry,
|
|
activeEntry: self.activeEntry,
|
|
|
|
|
+ trashEntry: self.trashEntry,
|
|
|
assistHelper: self.assistHelper,
|
|
assistHelper: self.assistHelper,
|
|
|
definition: definition,
|
|
definition: definition,
|
|
|
app: self.app,
|
|
app: self.app,
|
|
|
parent: self
|
|
parent: self
|
|
|
- })
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ if (entry.isTrash()) {
|
|
|
|
|
+ self.trashEntry(entry);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ newEntries.push(entry);
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
newEntries.sort(function (a, b) {
|
|
newEntries.sort(function (a, b) {
|
|
@@ -278,6 +300,7 @@
|
|
|
if (! self.parent && data.parent) {
|
|
if (! self.parent && data.parent) {
|
|
|
self.parent = new HueFileEntry({
|
|
self.parent = new HueFileEntry({
|
|
|
activeEntry: self.activeEntry,
|
|
activeEntry: self.activeEntry,
|
|
|
|
|
+ trashEntry: self.trashEntry,
|
|
|
assistHelper: self.assistHelper,
|
|
assistHelper: self.assistHelper,
|
|
|
definition: data.parent,
|
|
definition: data.parent,
|
|
|
app: self.app,
|
|
app: self.app,
|
|
@@ -299,6 +322,13 @@
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ HueFileEntry.prototype.showTrash = function () {
|
|
|
|
|
+ var self = this;
|
|
|
|
|
+ if (self.trashEntry()) {
|
|
|
|
|
+ self.trashEntry().open();
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
HueFileEntry.prototype.showDeleteConfirmation = function () {
|
|
HueFileEntry.prototype.showDeleteConfirmation = function () {
|
|
|
var self = this;
|
|
var self = this;
|
|
|
if (self.selectedEntries().length > 0) {
|
|
if (self.selectedEntries().length > 0) {
|