Implemented media sorting

This commit is contained in:
Matt@MBP13-PC
2012-08-16 10:03:37 -01:00
parent 0bc1234a4e
commit b057b6d68a
2 changed files with 19 additions and 11 deletions

View File

@@ -117,7 +117,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
});
self._viewModel.filtered = ko.computed(function () {
return self._viewModel.items();
//return self._viewModel.items();
return ko.utils.arrayFilter(this.items(), function (item) {
return item.Name().toLowerCase().indexOf(self._viewModel.filterTerm()) > -1 ||
item.Tags().toLowerCase().indexOf(self._viewModel.filterTerm()) > -1;
@@ -138,6 +138,14 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
return ids;
}, self._viewModel);
self._viewModel.itemIds = ko.computed(function () {
var ids = [];
ko.utils.arrayForEach(this.items(), function (item) {
ids.push(item.Id());
});
return ids;
}, self._viewModel);
self._viewModel.filterTerm.subscribe(function (newValue) {
self._getChildNodes();
});
@@ -346,7 +354,16 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
}
else
{
//TODO: Update on server
$.post(self._opts.umbracoPath + "/webservices/nodeSorter.asmx/UpdateSortOrder", {
ParentId : self._parentId,
SortOrder: self._viewModel.itemIds().join(","),
app: "media"
}, function (data, textStatus) {
if(textStatus == "error") {
alert("Oops. Could not update sort order");
self._getChildNodes();
}
}, "json");
}
}
});

View File

@@ -85,14 +85,5 @@ namespace Umbraco.Web.WebServices
success = true
});
}
[RestExtensionMethod(returnXml = false)]
public static string UpdateSortOrder(int parentId, IDictionary<int, int> map)
{
return new JavaScriptSerializer().Serialize(new
{
success = true
});
}
}
}