Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbrailsford committed Mar 16, 2018
2 parents 04feb1d + f4f7ca8 commit afdd0cb
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 43 deletions.
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
os: Visual Studio 2015

# version format
version: 1.0.1.{build}
version: 1.0.2.{build}

# UMBRACO_PACKAGE_PRERELEASE_SUFFIX if a rtm release build this should be blank, otherwise if empty will default to alpha
# example UMBRACO_PACKAGE_PRERELEASE_SUFFIX=beta
Expand All @@ -15,7 +15,7 @@ before_build:
- nuget restore src

build_script:
- build-appveyor.cmd
- build-appveyor.cmd

artifacts:
- path: artifacts\*.nupkg
Expand Down Expand Up @@ -47,7 +47,7 @@ deploy:
- provider: NuGet
server:
api_key:
secure: eSLiOXbGVrxSG+X7PV6qTTUZ5VzS9EFj5+EufaWPfd+QXkF6gc8rZ4mGoHIVp/fL
secure: 0+oAleUTnr9UuJrhLW5rphRR+QGz00XX1Ui3k5kwyr2kUdEamiQ3F+gW0q8MJbDT
artifact: /.*\.nupkg/
on:
branch: master
Expand Down
5 changes: 4 additions & 1 deletion docs/_pages/04-reference-01-known-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ Fluidity tries it's best to mimc the content pipeline as closely as possible whi

#### Tags

Whilst we have support for persisting the tags value, we don't currently have the ability to write these tags to the `cmsTags` DB table. Unfortunately this is all handled internally via a `tagsRepository` which is internal and so we currently can't save to it like core does.
Whilst we have support for persisting the tags value, we don't currently have the ability to write these tags to the `cmsTags` DB table. Unfortunately this is all handled via a `tagsRepository` which is internal and so we currently can't save to it like core does.

### Multi Node Tree Picker

When using a Multi Node Tree Picker with an XPath filter, only filters starting with the `$root` placeholder will be valid as all other placeholders expect the property editor to be placed on a content node, with that node being used as context.
4 changes: 2 additions & 2 deletions src/Fluidity/Configuration/FluidityPropertyConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public FluidityPropertyConfig(LambdaExpression propertyExp)
/// </returns>
public static implicit operator PropertyInfo(FluidityPropertyConfig propertyConfig)
{
return propertyConfig.PropertyInfo;
return propertyConfig?.PropertyInfo;
}

/// <summary>
Expand All @@ -56,7 +56,7 @@ public static implicit operator PropertyInfo(FluidityPropertyConfig propertyConf
/// </returns>
public static implicit operator LambdaExpression(FluidityPropertyConfig propertyConfig)
{
return propertyConfig.PropertyExpression;
return propertyConfig?.PropertyExpression;
}

/// <summary>
Expand Down
26 changes: 16 additions & 10 deletions src/Fluidity/Data/DefaultFluidityRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public object Get(object id, bool fireEvents = true)

public IEnumerable<object> GetAll(bool fireEvents = true)
{
var query = new Sql($"SELECT * FROM {_collection.EntityType.GetTableName()}");
var query = new Sql($"SELECT * FROM [{_collection.EntityType.GetTableName()}]");

if (_collection.DeletedProperty != null)
{
Expand All @@ -68,7 +68,7 @@ public IEnumerable<object> GetAll(bool fireEvents = true)

public PagedResult<object> GetPaged(int pageNumber, int pageSize, LambdaExpression whereClause, LambdaExpression orderBy, SortDirection orderDirection, bool fireEvents = true)
{
var query = new Sql($"SELECT * FROM {_collection.EntityType.GetTableName()}");
var query = new Sql($"SELECT * FROM [{_collection.EntityType.GetTableName()}]");

// Where
if (whereClause != null)
Expand All @@ -77,17 +77,17 @@ public PagedResult<object> GetPaged(int pageNumber, int pageSize, LambdaExpressi
}
else
{
query.Where(" 1 = 1");
query.Where("1 = 1");
}

if (_collection.DeletedProperty != null)
{
query.Append($" AND {_collection.DeletedProperty.GetColumnName()} = 0");
query.Append($" AND ({_collection.DeletedProperty.GetColumnName()} = 0)");
}

// Order by
LambdaExpression orderByExp = orderBy ?? _collection.SortProperty;
if (orderByExp != null)
if (orderByExp != null)
{
if (orderDirection == SortDirection.Ascending)
{
Expand All @@ -96,9 +96,15 @@ public PagedResult<object> GetPaged(int pageNumber, int pageSize, LambdaExpressi
else
{
SqlExtensions.OrderByDescending(query, _collection.EntityType, orderByExp, SyntaxProvider);

}
}
else
{
// There is a bug in the Db.Page code that effectively requires there
// to be an order by clause no matter what, so if one isn't provided
// we'lld just order by 1
query.Append(" ORDER BY 1 ");
}

var result = Db.Page(_collection.EntityType, pageNumber, pageSize, query);

Expand Down Expand Up @@ -132,7 +138,7 @@ public object Save(object entity, bool fireEvents = true)
entity = args.Entity.After;
}

Db.Save(args.Entity.After);
Db.Save(entity);

if (fireEvents)
{
Expand Down Expand Up @@ -164,8 +170,8 @@ public void Delete(object id, bool fireEvents = true)
}

var query = new Sql(_collection.DeletedProperty != null
? $"UPDATE {_collection.EntityType.GetTableName()} SET {_collection.DeletedProperty.GetColumnName()} = 1 WHERE {_collection.IdProperty.GetColumnName()} = @0"
: $"DELETE FROM {_collection.EntityType.GetTableName()} WHERE {_collection.IdProperty.GetColumnName()} = @0",
? $"UPDATE [{_collection.EntityType.GetTableName()}] SET {_collection.DeletedProperty.GetColumnName()} = 1 WHERE {_collection.IdProperty.GetColumnName()} = @0"
: $"DELETE FROM [{_collection.EntityType.GetTableName()}] WHERE {_collection.IdProperty.GetColumnName()} = @0",
id);

Db.Execute(query);
Expand All @@ -176,7 +182,7 @@ public void Delete(object id, bool fireEvents = true)

public long GetTotalRecordCount(bool fireEvents = true)
{
var sql = $"SELECT COUNT(1) FROM {_collection.EntityType.GetTableName()}";
var sql = $"SELECT COUNT(1) FROM [{_collection.EntityType.GetTableName()}]";

if (_collection.DeletedProperty != null)
{
Expand Down
6 changes: 6 additions & 0 deletions src/Fluidity/Web/Models/FluidityListViewDisplayModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ public class FluidityListViewDisplayModel
[DataMember(Name = "pageSize")]
public int PageSize { get; set; }

[DataMember(Name = "defaultOrderBy")]
public string DefaultOrderBy { get; set; }

[DataMember(Name = "defaultOrderDirection")]
public string DefaultOrderDirection { get; set; }

[DataMember(Name = "bulkActions")]
public IEnumerable<FluidityListViewBulkActionDisplayModel> BulkActions { get; set; }

Expand Down
4 changes: 3 additions & 1 deletion src/Fluidity/Web/Models/Mappers/FluidityCollectionMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ public FluidityCollectionDisplayModel ToDisplayModel(FluiditySectionConfig secti
Path = collection.Path
};

if (includeListView)
if (includeListView && m.HasListView)
{
m.ListView = new FluidityListViewDisplayModel
{
PageSize = collection.ListView.PageSize,
DefaultOrderBy = collection.SortProperty?.Name ?? "Name",
DefaultOrderDirection = collection.SortDirection == SortDirection.Ascending ? "asc" : "desc",
Properties = collection.ListView.Fields.Select(x =>
{
// Calculate heading
Expand Down
32 changes: 15 additions & 17 deletions src/Fluidity/Web/Models/Mappers/FluidityEntityMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,27 @@ public FluidityEntityDisplayModel ToDisplayModel(FluiditySectionConfig section,
EditPath = $"{section.Alias}/fluidity/edit/{entityCompositeId}",
};

if (collection.Editor?.Tabs != null)
if (collection.ListView != null)
{
var properties = new List<ContentPropertyBasic>();
if (collection.ListView != null)

foreach (var field in collection.ListView.Fields)
{
foreach (var field in collection.ListView.Fields)
{
var value = entity?.GetPropertyValue(field.Property);
var value = entity?.GetPropertyValue(field.Property);

if (field.Format != null)
{
value = field.Format(value, entity);
}
if (field.Format != null)
{
value = field.Format(value, entity);
}

var propertyScaffold = new ContentPropertyBasic
{
Id = properties.Count,
Alias = field.Property.Name,
Value = value?.ToString()
};
var propertyScaffold = new ContentPropertyBasic
{
Id = properties.Count,
Alias = field.Property.Name,
Value = value?.ToString()
};

properties.Add(propertyScaffold);
}
properties.Add(propertyScaffold);
}

display.Properties = properties;
Expand Down
5 changes: 4 additions & 1 deletion src/Fluidity/Web/Trees/FluidityTreeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,14 @@ protected TreeNode CreateEntityTreeNode(FluidityCollectionConfig collection, obj
var itemId = entity.GetPropertyValue(collection.IdProperty);
var compositeId = collection.Alias + "!" + itemId;

var entityName = collection.NameProperty != null ? entity.GetPropertyValue(collection.NameProperty).ToString()
: collection.NameFormat != null ? collection.NameFormat(entity) : entity.ToString();

var node = CreateTreeNode(
compositeId,
collection.Alias,
queryStrings,
collection.NameFormat != null ? collection.NameFormat(entity) : entity.ToString(),
entityName,
collection.IconSingular,
false,
SectionAlias + "/fluidity/edit/" + compositeId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
options: {
isSearchable: true,
pageSize: 10,
defaultOrderBy: "Name",
defaultOrderDirection: "desc",
bulkActions: [],
dataViews: [],
layouts: [],
Expand All @@ -34,12 +36,14 @@

function init(collection) {
$scope.page.name = collection.namePlural;
$scope.listView.options.isSearchable = collection.isSearchable;
$scope.listView.options.pageSize = collection.listView.pageSize;
$scope.listView.options.bulkActions = collection.listView.bulkActions;
$scope.listView.options.dataViews = collection.listView.dataViews;
$scope.listView.options.layouts = collection.listView.layouts;
$scope.listView.options.properties = collection.listView.properties;
$scope.listView.options.isSearchable = collection.isSearchable;
$scope.listView.options.pageSize = collection.listView.pageSize;
$scope.listView.options.defaultOrderBy = collection.listView.defaultOrderBy;
$scope.listView.options.defaultOrderDirection = collection.listView.defaultOrderDirection;
$scope.listView.options.bulkActions = collection.listView.bulkActions;
$scope.listView.options.dataViews = collection.listView.dataViews;
$scope.listView.options.layouts = collection.listView.layouts;
$scope.listView.options.properties = collection.listView.properties;
}

function syncTree(entity, path, initialLoad) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
$scope.options = angular.extend({}, {
pageNumber: ($routeParams.page && Number($routeParams.page) != NaN && Number($routeParams.page) > 0) ? $routeParams.page : 1,
pageSize: $scope.opts.pageSize,
orderBy: "name",
orderDirection: "desc",
orderBy: $scope.opts.defaultOrderBy || "name",
orderDirection: $scope.opts.defaultOrderDirection || "desc",
filter: '', // Variable has to be named "filter" to work with list view properly
dataView: fluidityUtilityService.recallDataView($routeParams.id, $scope.opts.dataViews), // TODO: Remember the dataview like how the layout persists
dataViews: $scope.opts.dataViews,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,30 @@

angular.module("umbraco.services").config(['$provide', fluidityUmbracoServicesOverrides]);

// Umbraco resource overrides
function fluidityUmbracoResourceOverrides($provide) {

$provide.decorator('entityResource', function ($delegate) {

// When using MNTP with an xpath filter with fluidity
// a call to getByQuery is made using the $routeParams.id
// as context. Unfortunately it expects that variable to
// be an int, which in fluidity's case is not, so we
// intercept the call and just set it to the root id.
var oldGetByQuery = $delegate.getByQuery;
$delegate.getByQuery = function () {
if (arguments.length >= 2 && arguments[1].toString().indexOf('!') >= 0) { // '!' signifies a fluidity composite id
arguments[1] = -1;
}
return oldGetByQuery.apply($delegate, arguments);
};

return $delegate;

});

}

angular.module("umbraco.resources").config(['$provide', fluidityUmbracoResourceOverrides]);

})();

0 comments on commit afdd0cb

Please sign in to comment.