enables the super rough search data in navigation

This commit is contained in:
perploug
2013-09-26 22:56:01 +02:00
parent c9ce0117b9
commit afb5139aec
8 changed files with 80 additions and 58 deletions

View File

@@ -206,18 +206,19 @@ function entityResource($q, $http, umbRequestHelper) {
* @methodOf umbraco.resources.entityResource
*
* @description
* Gets an array of entities, given a lucene query
* Gets an array of entities, given a lucene query and a type
*
* ##usage
* <pre>
* entityResource.search("news")
* entityResource.search("news", "Media")
* .then(function(mediaArray) {
* var myDoc = mediaArray;
* alert('they are here!');
* });
* </pre>
*
* @param {String} Query search query
* @param {String} Query search query
* @param {String} Type type of conten to search
* @returns {Promise} resourcePromise object containing the entity array.
*
*/
@@ -227,7 +228,7 @@ function entityResource($q, $http, umbRequestHelper) {
$http.get(
umbRequestHelper.getApiUrl(
"entityApiBaseUrl",
"SearchMedia",
"Search",
[{ query: query }, {type: type}])),
'Failed to retreive entity data for query ' + query);
}

View File

@@ -1,39 +1,48 @@
angular.module('umbraco.services')
.factory('searchService', function () {
.factory('searchService', function ($q, $log, entityResource) {
var m = {results: []};
return {
search: function(term, section){
return [
{
section: "settings",
tree: "documentTypes",
matches:[
{ name: "News archive", path:"/News Archive", id: 1234, icon: "icon-list-alt", view: section + "/edit/" + 1234, children: [], expanded: false, level: 1 },
{ name: "Meta Data", path:"/Seo/Meta Data", id: 1234, icon: "icon-list-alt", view: section + "/edit/" + 1234, children: [], expanded: false, level: 1 },
{ name: "Dooo", path:"/Woop/dee/dooo", id: 1234, icon: "icon-list-alt red", view: section + "/edit/" + 1234, children: [], expanded: false, level: 1 }
]
},
{
section: "content",
tree: "content",
matches:[
{ name: "News", path:"/archive/news", id: 1234, icon: "icon-file", view: section + "/edit/" + 1234, children: [], expanded: false, level: 1 },
{ name: "Data types", path:"/Something/About/Data-Types", id: 1234, icon: "icon-file", view: section + "/edit/" + 1234, children: [], expanded: false, level: 1 },
{ name: "Dooo", path:"/Woop/dee/dooo", id: 1234, icon: "icon-file", view: section + "/edit/" + 1234, children: [], expanded: false, level: 1 }
]
},
results: m,
search: function(term){
m.results.length = 0;
{
section: "developer",
tree: "macros",
matches:[
{ name: "Navigation", path:"/Macros/Navigation.xslt", id: 1234, icon: "icon-cogs", view: section + "/edit/" + 1234, children: [], expanded: false, level: 1 },
{ name: "List of stuff", path:"/Macros/Navigation.xslt", id: 1234, icon: "icon-cogs", view: section + "/edit/" + 1234, children: [], expanded: false, level: 1 },
{ name: "Something else", path:"/Macros/Navigation.xslt",id: 1234, icon: "icon-cogs", view: section + "/edit/" + 1234, children: [], expanded: false, level: 1 }
]
}
];
var deferred = $q.defer();
var i = 0;
entityResource.search(term, "Document").then(function(data){
$log.log(data);
m.results.push({
icon: "icon-document",
editor: "content/content/edit/",
matches: data
});
i++;
//deferred.notify(results);
if(i === 2){
deferred.resolve(m);
}
});
entityResource.search(term, "Media").then(function(data){
$log.log(data);
m.results.push({
icon: "icon-picture",
editor: "media/media/edit/",
matches: data
});
i++;
if(i === 2){
deferred.resolve(m);
}
});
return deferred.promise;
},
setCurrent: function(sectionAlias){

View File

@@ -8,21 +8,21 @@
*
*/
function SearchController($scope, searchService, $log, navigationService) {
var currentTerm = "";
navigationService.ui.search = searchService.results;
$scope.deActivateSearch = function () {
currentTerm = "";
};
$scope.performSearch = function (term) {
if (term != undefined && term != currentTerm) {
if (term.length > 3) {
navigationService.ui.selectedSearchResult = -1;
navigationService.showSearch();
currentTerm = term;
navigationService.ui.searchResults = searchService.search(term, navigationService.currentSection);
} else {
navigationService.ui.searchResults = [];
}
searchService.search(term);
}
};

View File

@@ -39,6 +39,8 @@ function ContentEditController($scope, $routeParams, $q, $timeout, $window, cont
//TODO: Need to figure out a way to share the saving and event broadcasting with all editors!
$scope.saveAndPublish = function () {
$scope.setStatus("Publishing...");
$scope.$broadcast("saving", { scope: $scope });
var currentForm = angularHelper.getRequiredCurrentForm($scope);

View File

@@ -43,7 +43,7 @@
<input type="text"
ng-model="nav.ui.searchTerm"
class="umb-search-field search-query"
placeholder="{{localization.app.search.typeToSearch}}"
placeholder="Type to search..."
on-blur="deActivateSearch()"
on-keyup="performSearch(nav.ui.searchTerm)">
</form>
@@ -55,16 +55,14 @@
ng-show="nav.ui.showSearchResults">
<h5 class="umb-tree-header">Search results</h5>
<ul class="umb-item-list" ng-repeat="resultGroup in nav.ui.searchResults">
<li class="umb-icon-item" ng-class="{selected:$index==nav.ui.selectedSearchResult}" ng-repeat="result in resultGroup.matches">
<i class="icon umb-tree-icon sprTree {{result.icon}}" ng-show="$first"></i>
<a ng-href="#{{result.view}}">{{result.name}}
<small>{{result.path}}</small>
</a>
<i class="umb-options" ng-click="nav.showMenu(result, $event)"><i></i><i></i><i></i></i>
<ul class="umb-item-list nav nav-stacked" ng-repeat="resultGroup in nav.ui.search.results">
<li ng-repeat="result in resultGroup.matches">
<a ng-href="#/{{resultGroup.editor}}{{result.id}}">
<i class="icon umb-tree-icon sprTree {{resultGroup.icon}}"
ng-show="$first"></i>
{{result.name}}
</a>
</li>
</ul>
</div>

View File

@@ -11,11 +11,12 @@
<div class="span8">
<div class="btn-toolbar pull-right umb-btn-toolbar">
<div class="btn-group">
<button type="submit" class="btn btn-success">Save</button>
<div class="btn-group" ng-animate="'fade'" ng-show="status">
<p class="btn btn-link umb-status-label">{{status}}</p>
</div>
<div class="btn-group">
<button type="submit" data-hotkey="ctrl+s" class="btn btn-success">Save</button>
</div>
</div>
</div>

View File

@@ -37,9 +37,19 @@ function mediaEditController($scope, $routeParams, mediaResource, notificationsS
});
}
$scope.setStatus = function(status){
//add localization
$scope.status = status;
$timeout(function(){
$scope.status = undefined;
}, 2500);
};
$scope.save = function () {
$scope.setStatus("Saving...");
$scope.$broadcast("saving", { scope: $scope });
var currentForm = angularHelper.getRequiredCurrentForm($scope);

View File

@@ -32,7 +32,8 @@ namespace Umbraco.Web.Editors
/// </remarks>
[PluginController("UmbracoApi")]
public class EntityController : UmbracoAuthorizedJsonController
{
{
[HttpGet]
public IEnumerable<EntityBasic> Search([FromUri] string query, UmbracoEntityTypes type)
{
switch (type)