Skip to content

Commit

Permalink
Minor changes - Admin search
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzysztofPajak committed Sep 17, 2018
1 parent 06bc1a3 commit 4dd8fa2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
8 changes: 7 additions & 1 deletion Grand.Web/Areas/Admin/Controllers/AdminSearchController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ public class AdminSearchController : BaseAdminController
private readonly IOrderService _orderService;
private readonly AdminSearchSettings _adminSearchSettings;
private readonly ILocalizationService _localizationService;
private readonly IWorkContext _workContext;

public AdminSearchController(IProductService productService, ICategoryService categoryService, IManufacturerService manufacturerService,
ITopicService topicService, INewsService newsService, IBlogService blogService, ICustomerService customerService, IOrderService orderService,
AdminSearchSettings adminSearchSettings, ILocalizationService localizationService)
AdminSearchSettings adminSearchSettings, ILocalizationService localizationService, IWorkContext workContext)
{
this._productService = productService;
this._categoryService = categoryService;
Expand All @@ -43,6 +44,7 @@ public AdminSearchController(IProductService productService, ICategoryService ca
this._orderService = orderService;
this._adminSearchSettings = adminSearchSettings;
this._localizationService = localizationService;
this._workContext = workContext;
}

[HttpPost]
Expand All @@ -51,6 +53,10 @@ public IActionResult Search(string searchTerm, FoundMenuItem[] foundMenuItems)
if (string.IsNullOrEmpty(searchTerm))
return Json("error");

if(!_workContext.CurrentCustomer.IsAdmin())
{
return Json("Access Denied");
}
//object = actual result, int = display order for sorting
List<Tuple<object, int>> result = new List<Tuple<object, int>>();

Expand Down
19 changes: 11 additions & 8 deletions Grand.Web/Areas/Admin/Views/Shared/_AdminLayout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,17 @@
</ul>
</div>
</div>
<div class="input-group">
<input id="searchInput" type="text" class="form-control" placeholder="@T("AdminSearch.Placehloder")">
<script>
$(document).ready(function () {
Admin.Search.init("@(Url.Action("Search", "AdminSearch"))");
});
</script>
</div>
@if (currentCustomer.IsAdmin())
{
<div class="input-group admin-search-input-container">
<input id="searchInput" type="text" class="form-control" placeholder="@T("AdminSearch.Placehloder")">
<script>
$(document).ready(function () {
Admin.Search.init("@(Url.Action("Search", "AdminSearch"))");
});
</script>
</div>
}
</div>
}
@await Component.InvokeAsync("AdminWidget", new { widgetZone = "admin_header_after" })
Expand Down
7 changes: 6 additions & 1 deletion Grand.Web/wwwroot/Administration/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,13 @@ textarea.form-control.k-input {
margin: 0;
}

.admin-search-input-container {
display: flex;
max-width: 500px;
width: auto;
}

#searchInput {
width: 500px;
margin: 10px;
}

Expand Down

0 comments on commit 4dd8fa2

Please sign in to comment.