Skip to content

Commit ba89aec

Browse files
Merge pull request umbraco#415 from rustyswayne/7.1.5-templatequery
Query Builder - Fix Date sort fields and format returned query
2 parents 4366500 + 2953382 commit ba89aec

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@
7979
template: "views/common/dialogs/template/queryBuilder.html",
8080
callback: function (data) {
8181

82-
var code = "\n@{\n" + "\tvar selection = " + data + ";\n}\n";
82+
var dataFormatted = data.replace(new RegExp('[' + "." + ']', 'g'), "\n\t\t\t\t\t.");
83+
84+
var code = "\n@{\n" + "\tvar selection = " + dataFormatted + ";\n}\n";
8385
code += "<ul>\n" +
8486
"\t@foreach(var item in selection){\n" +
8587
"\t\t<li>\n" +

src/Umbraco.Web/Editors/TemplateQuery/TemplateQueryController.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ public TemplateQueryController(UmbracoContext umbracoContext)
5959

6060
private static readonly IEnumerable<PropertyModel> _properties = new List<PropertyModel>()
6161
{
62-
new PropertyModel() { Name = "Id", Alias = "id", Type = "int" },
63-
new PropertyModel() { Name = "Name", Alias = "name", Type = "string" },
62+
new PropertyModel() { Name = "Id", Alias = "Id", Type = "int" },
63+
new PropertyModel() { Name = "Name", Alias = "Name", Type = "string" },
6464
//new PropertyModel() { Name = "Url", Alias = "url", Type = "string" },
65-
new PropertyModel() { Name = "Creation Date", Alias = "createDate", Type = "datetime" },
66-
new PropertyModel() { Name = "Publishing Date", Alias = "publishDate", Type = "datetime" }
65+
new PropertyModel() { Name = "Created Date", Alias = "CreateDate", Type = "datetime" },
66+
new PropertyModel() { Name = "Last Updated Date", Alias = "UpdateDate", Type = "datetime" }
6767

6868
};
6969

@@ -82,7 +82,6 @@ public QueryResultModel PostTemplateQuery(QueryModel model)
8282
timer.Start();
8383

8484
var currentPage = umbraco.TypedContentAtRoot().FirstOrDefault();
85-
8685
timer.Stop();
8786

8887

@@ -201,7 +200,7 @@ public QueryResultModel PostTemplateQuery(QueryModel model)
201200

202201
var direction = model.Sort.Direction == "ascending" ? string.Empty : " desc";
203202

204-
sb.AppendFormat(".OrderBy(\"{0}{1}\")", model.Sort.Property.Name, direction);
203+
sb.AppendFormat(".OrderBy(\"{0}{1}\")", model.Sort.Property.Alias, direction);
205204
}
206205

207206
if (model.Take > 0)

0 commit comments

Comments
 (0)