Compare commits
463 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9a2e14d8f6 | |||
| 7d8a6e28fa | |||
| 6a9c56df58 | |||
| 078f4a506e | |||
| a54170b915 | |||
| 757ba890f5 | |||
| a127dac03a | |||
| 77ec2d7a9c | |||
| 0d55f0ed86 | |||
| 6a7ac205bc | |||
| 1cb2139137 | |||
| b9179f4140 | |||
| bae1ee508b | |||
| 20b6a78af1 | |||
| 014b407abb | |||
| 5aa16a6636 | |||
| 7206bba46a | |||
| af9db94fb6 | |||
| d2014be81b | |||
| 01b8b3b508 | |||
| 734125fa25 | |||
| 76678f538d | |||
| 7fe23fdf4c | |||
| c956c12cdf | |||
| 8706feb882 | |||
| c8364986a2 | |||
| 4d24150bdc | |||
| a16c4b4da9 | |||
| 75a312c309 | |||
| aa6505d7f6 | |||
| 6ed7af28bc | |||
| 526f4c147a | |||
| bb0df72dc7 | |||
| 3cba5677bf | |||
| c4f88ab528 | |||
| 7bc9584940 | |||
| 17be4b4253 | |||
| 2db196af6a | |||
| b4b27cd1f8 | |||
| a2cc052944 | |||
| 4d8a4f0b12 | |||
| 743f37c45f | |||
| 1ba45969ee | |||
| 349d6f69b3 | |||
| 9431a70156 | |||
| ab780f72a4 | |||
| 7d01be305f | |||
| 694b932e37 | |||
| a4f6334761 | |||
| 9316e7c3f6 | |||
| 8bc6c17921 | |||
| 1161c7e6da | |||
| 93db3eb2ee | |||
| b7b166562f | |||
| e3c4c91de1 | |||
| f79849cf8a | |||
| f0b27e1507 | |||
| 42e92a4e74 | |||
| 2c363a5d37 | |||
| 738e9282b6 | |||
| 20fa1efc8e | |||
| 718f2deb47 | |||
| 1cea5d156a | |||
| 109d4c7708 | |||
| 8306be60de | |||
| 27d0cb742b | |||
| 62a250cd83 | |||
| 6f94d608db | |||
| 854e9873c8 | |||
| 2a6d5eaddf | |||
| 3d7ddb58c2 | |||
| 4c7496840d | |||
| d816103981 | |||
| b38ccc12f6 | |||
| e1deba5b95 | |||
| 5bce4e856a | |||
| 6f4cb1e609 | |||
| 033cbbc8f6 | |||
| 7ee3cfca5c | |||
| e9b478c186 | |||
| 21e784424f | |||
| 155355aa00 | |||
| abf6917b1c | |||
| 40ad701f7f | |||
| a8113f926c | |||
| 3c527396de | |||
| 59bf66dcd1 | |||
| c125042a86 | |||
| 85ea472129 | |||
| f541b50b82 | |||
| 5767ea97d1 | |||
| e1fa7a3271 | |||
| c2e97e28ce | |||
| eda9bab02f | |||
| ce3cecbec9 | |||
| ef5faae254 | |||
| 547473e92c | |||
| 9857059906 | |||
| 7f7b054c14 | |||
| a40d95250e | |||
| 1e6004d3fa | |||
| 0671403732 | |||
| 8e00914370 | |||
| 104c369bcc | |||
| 4c02cf2921 | |||
| 74470b8e8f | |||
| de92147ec0 | |||
| c2b7d2c89d | |||
| d0fe30f08b | |||
| d22ae1244e | |||
| fa48d73630 | |||
| fb305c9d0e | |||
| be332d310f | |||
| d97bbb59dc | |||
| 3702ec484b | |||
| d8d4ec1a73 | |||
| 32cb89bba1 | |||
| 863f041fc9 | |||
| 5a83719dfc | |||
| 1b1940fe6a | |||
| b71564bfb5 | |||
| ba8a6cf65c | |||
| 7dd07b9f9c | |||
| 29652bb880 | |||
| 62b7420eaa | |||
| 333f17976b | |||
| 45981b0431 | |||
| 531ff0aab4 | |||
| 394572a8fc | |||
| c7114b63f5 | |||
| 9704a8b591 | |||
| 0b6af3b4e1 | |||
| 4b874dc5b5 | |||
| a081d97546 | |||
| ebf3fd1135 | |||
| 85157612f4 | |||
| 6b79a508bb | |||
| f57205dab9 | |||
| b6ccab10b3 | |||
| e1f67a738b | |||
| 4410f1bb81 | |||
| 5c2a99987a | |||
| 715a2bf6d5 | |||
| d9ffb4b097 | |||
| c409922469 | |||
| 6b40d1e20b | |||
| 3e91b1c2c3 | |||
| 38eafc0063 | |||
| 89aeca9bf0 | |||
| 2b6d87d97c | |||
| 1ca113b455 | |||
| 8228b2dae5 | |||
| 22f24ec882 | |||
| e33eb863e6 | |||
| 6bcf291c99 | |||
| b0f614c891 | |||
| a424a7e4f3 | |||
| 75fa2bb1bb | |||
| 5585244d32 | |||
| 41fa8fa40d | |||
| 9336f4508a | |||
| f9e5012b4e | |||
| 61d215e16c | |||
| e1e34be10d | |||
| 796be76d94 | |||
| 8f7024c32a | |||
| dea307ff8e | |||
| d69a10de48 | |||
| b93df7a4c0 | |||
| 48dbdebec5 | |||
| 65837fa74c | |||
| 29a73336e3 | |||
| 0dfa8edc95 | |||
| 0584c4eda5 | |||
| 4eb901fbba | |||
| b7875dd850 | |||
| 19989e556e | |||
| 9250d66953 | |||
| fa0b1a4b3b | |||
| 73e875e67c | |||
| e061311689 | |||
| b36f83eaf6 | |||
| d63f7a6a34 | |||
| 68c2f55111 | |||
| f22d3cdef3 | |||
| 13b59d0d61 | |||
| 188c09d3c1 | |||
| 6d8770907c | |||
| efbed9606d | |||
| c862ecc36f | |||
| 523630416f | |||
| 990836bc37 | |||
| bb194fff76 | |||
| 16351df692 | |||
| 213d3940ca | |||
| 8dfe1f3ca4 | |||
| 3291998171 | |||
| e640a9b4f4 | |||
| 7df4d4cfcd | |||
| bb056a01dd | |||
| 608b12aa10 | |||
| 6494327c77 | |||
| 293aa7f6f3 | |||
| 7e76e98c0f | |||
| f4e449f030 | |||
| 1e97caa7e8 | |||
| b0dcefaf06 | |||
| 716972bc17 | |||
| 4d4eab39e8 | |||
| 6acaf65ec3 | |||
| a2b2567350 | |||
| f5f4e80800 | |||
| b42695bd0d | |||
| f405239115 | |||
| 4be6a13fc0 | |||
| 99638ed0b0 | |||
| fd28df1bad | |||
| 165a98c89e | |||
| ca1214a09a | |||
| 17062c6913 | |||
| 16e73446fd | |||
| e56356534e | |||
| 21b933a0dc | |||
| e3a2b66022 | |||
| 645198444b | |||
| 0e9bef9048 | |||
| bd4398ff28 | |||
| a4f371a4ca | |||
| e465861da6 | |||
| 3fdfa2b2c6 | |||
| 9787af9ed6 | |||
| b8fc0fb71c | |||
| de7ed9328d | |||
| ee8b16eb9b | |||
| 5465c1c899 | |||
| 3402f216b9 | |||
| 490de7b3ff | |||
| 275b5d2207 | |||
| bc19e6dda1 | |||
| 3904b6527e | |||
| d5fd59b954 | |||
| e01c50f08a | |||
| 1e9c7d0a6c | |||
| 3cf153fc80 | |||
| 8e11a33031 | |||
| 5c95f59219 | |||
| 01b59f28f1 | |||
| f40e023420 | |||
| 6d9c32e30d | |||
| 2f48e9da9a | |||
| 2aa71e48a3 | |||
| e6732d2a37 | |||
| a7dca93781 | |||
| 0ec0e213a2 | |||
| 6919c5a8b4 | |||
| 6505323297 | |||
| ec8df1d465 | |||
| 451f2773a4 | |||
| f366305583 | |||
| 43a72ed5e5 | |||
| 709198f943 | |||
| 77f72ed72e | |||
| a03fe3af32 | |||
| 697a797c7e | |||
| cfe014ee45 | |||
| d62fa05ab5 | |||
| 662cf4c3bf | |||
| d0b8314134 | |||
| 8eb4786976 | |||
| 20155b5ca6 | |||
| 16c310f3c6 | |||
| 99d570dc97 | |||
| 2ae3e3ade9 | |||
| d4718e358c | |||
| bb91eb7036 | |||
| 484f2c22a3 | |||
| a2121cd8a7 | |||
| 2fb922fd6c | |||
| c2986d39a9 | |||
| 8ee5488261 | |||
| c60c9e1c5d | |||
| 8610f69c88 | |||
| 34b4209de7 | |||
| b6145c9275 | |||
| f51ca65659 | |||
| d026af9fd2 | |||
| 11fff5da1a | |||
| 788a5dd720 | |||
| 24e232b2cc | |||
| 5bdcb23933 | |||
| 34b3ed3b47 | |||
| 50a486a9ac | |||
| 4f4128a744 | |||
| 4851797a83 | |||
| 54a435dce7 | |||
| 03a170d716 | |||
| 37976abc84 | |||
| f7e96438be | |||
| f1c3caae2d | |||
| 8f8078e12f | |||
| dbc9b872d8 | |||
| eef1b94586 | |||
| 9bbf366fe2 | |||
| 368a9f6c07 | |||
| d3b3f80f3d | |||
| 11f7881dd7 | |||
| 9894357469 | |||
| 146a3770a1 | |||
| caf9d1ac15 | |||
| 614595ceb3 | |||
| d1b21a1ca7 | |||
| 54bc507049 | |||
| 037585458c | |||
| f52649eb9e | |||
| 423fedb954 | |||
| b39312ccd2 | |||
| b9c4be0bb6 | |||
| 29285607a9 | |||
| 909b87cea0 | |||
| 3d25f75fb9 | |||
| 6fa713f88e | |||
| d9982fe3a2 | |||
| 588bdfe429 | |||
| 0174f6d78b | |||
| 84144b6206 | |||
| 27910e8d22 | |||
| 9bf413207f | |||
| e5cd3d0cb0 | |||
| 032ee958c1 | |||
| ef5bd7ccc8 | |||
| 7839e4a992 | |||
| 408c178348 | |||
| 852b7a92a7 | |||
| 5a4118a1cc | |||
| 4b603bf97f | |||
| c8884c8d92 | |||
| dd843ce2c6 | |||
| 8036ab72d0 | |||
| b25d8bdc4b | |||
| 023d99cc88 | |||
| 1cc0586c75 | |||
| a16b61f03f | |||
| 7ea01cad86 | |||
| aea65a531d | |||
| 482cb5a149 | |||
| 81ac5fbddb | |||
| 801baf355b | |||
| a3b531caa4 | |||
| 1d680c612e | |||
| cdea3c1aec | |||
| 37fa9c40d6 | |||
| 774ba46e13 | |||
| 280a97c8d1 | |||
| 7dd3848bdf | |||
| add44e533a | |||
| 870b848e3b | |||
| b262d8a86f | |||
| 5dba1a0895 | |||
| 8f4857aba1 | |||
| cd95404a08 | |||
| 7e7a4aff58 | |||
| c9d8952b7f | |||
| 890b5674a6 | |||
| 7f5dbd31c9 | |||
| a2255aa037 | |||
| 415a84f5c0 | |||
| 3a0eba401a | |||
| 991d56dac1 | |||
| f704088bcb | |||
| a599215620 | |||
| a6e76cb398 | |||
| 4fd134ac74 | |||
| 22b87c0a37 | |||
| d707b55362 | |||
| 37a195109c | |||
| 205919ccae | |||
| 04e57b7d6b | |||
| 9e8cc0c556 | |||
| 8fe90c3b86 | |||
| 99581b0aeb | |||
| d8939c59a0 | |||
| e49fe6ee17 | |||
| ca52f0a216 | |||
| 08d4e4b51d | |||
| e9c51ee96e | |||
| b5f281cae0 | |||
| 3bbb27f85e | |||
| 247eea3477 | |||
| 8635fa7301 | |||
| e49a8d947d | |||
| 3e2e43d342 | |||
| 78ba99a52e | |||
| 42efa1a3d4 | |||
| d2f4fce808 | |||
| d76a5f58d4 | |||
| f6457416cc | |||
| c841813a74 | |||
| bcc7be94e7 | |||
| e200c22244 | |||
| 244db7f19d | |||
| 31f3d00b76 | |||
| 07125bae84 | |||
| f2a8286f00 | |||
| 5725c0770e | |||
| 210fbb8230 | |||
| c8e398c726 | |||
| bfa882fa01 | |||
| 876aea4007 | |||
| 07750c7537 | |||
| 17a1577d09 | |||
| 987f383139 | |||
| dc14f11f83 | |||
| 500f4c4dee | |||
| a16451df1f | |||
| 9ac7877174 | |||
| 4d3bcb68b3 | |||
| 30074fe198 | |||
| 7f0bd45a9d | |||
| 6045eed5c5 | |||
| 57ffa69ff5 | |||
| 6b61dc978a | |||
| c20aa64af2 | |||
| 25826958a3 | |||
| b5bfbb5c25 | |||
| 9afaa024c0 | |||
| c58dcd80ff | |||
| b7c16ee6ef | |||
| 786c547e0b | |||
| fbf686f559 | |||
| 42b4076700 | |||
| 5feb415093 | |||
| 79c85cf86b | |||
| a0f65370c9 | |||
| 029d17c428 | |||
| e262d7b0c9 | |||
| 44ea6c56f5 | |||
| d7477eaf6d | |||
| c33649201f | |||
| 3940955360 | |||
| 03f66a35f7 | |||
| b4b60dd89c | |||
| 4105912394 | |||
| 7b3d31f897 | |||
| 50861badf1 | |||
| fa682c3717 | |||
| d18d1ff0b1 | |||
| 247491187a | |||
| 80194786a1 | |||
| 72ee7b3d09 | |||
| 284b1d93dc | |||
| 7c5a3c34e2 | |||
| fa970750d1 | |||
| aeeb3c7b40 | |||
| 1cbb7b3173 | |||
| 71be453ada | |||
| efae05b3ae | |||
| 84acd43ccf | |||
| 9fe756bacb | |||
| cd03b5a4f9 | |||
| 07a62d7edf | |||
| a6c166d926 | |||
| c1bc555443 | |||
| d4166f33e8 |
+5
-1
@@ -17,6 +17,9 @@ tmp/
|
||||
pkg/*.nupkg
|
||||
pkg/*.zip
|
||||
|
||||
*_versioned*
|
||||
|
||||
|
||||
[Dd]ebug/
|
||||
[Bb]uild/
|
||||
[Rr]elease/
|
||||
@@ -59,4 +62,5 @@ VersionInfo.cs
|
||||
.builds
|
||||
.svn
|
||||
.hg
|
||||
.hgignore
|
||||
.hgignore
|
||||
app/Umbraco/.vs/config/applicationhost.config
|
||||
+176
-67
@@ -1,13 +1,38 @@
|
||||
module.exports = function(grunt) {
|
||||
require('load-grunt-tasks')(grunt);
|
||||
var path = require('path')
|
||||
|
||||
var path = require('path');
|
||||
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
pkgMeta: grunt.file.readJSON('config/meta.json'),
|
||||
dest: grunt.option('target') || 'dist',
|
||||
basePath: path.join('<%= dest %>', 'App_Plugins', '<%= pkgMeta.name %>'),
|
||||
|
||||
'string-replace': {
|
||||
version: {
|
||||
files: {
|
||||
"app/controllers/controller_versioned.js": "app/controllers/controller.js",
|
||||
"app/less/archetype_versioned.less": "app/less/archetype.less",
|
||||
"app/views/archetype.config.developer.dialog_versioned.html": "app/views/archetype.config.developer.dialog.html",
|
||||
"app/views/archetype.config.stylescript.dialog_versioned.html": "app/views/archetype.config.stylescript.dialog.html",
|
||||
"app/views/archetype.config.fieldset.dialog_versioned.html": "app/views/archetype.config.fieldset.dialog.html",
|
||||
"app/views/archetype.config_versioned.html": "app/views/archetype.config.html",
|
||||
"app/views/archetype_versioned.html": "app/views/archetype.html",
|
||||
"app/views/archetype.default_versioned.html": "app/views/archetype.default.html"
|
||||
},
|
||||
options: {
|
||||
replacements: [{
|
||||
pattern: /{{VERSION}}/g,
|
||||
replacement: '/* Version <%= pkgMeta.version %> */'
|
||||
},
|
||||
{
|
||||
pattern: /{{VERSION_HTML}}/g,
|
||||
replacement: '<!-- Version <%= pkgMeta.version %> -->'
|
||||
}]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
options: {
|
||||
spawn: false,
|
||||
@@ -16,22 +41,27 @@ module.exports = function(grunt) {
|
||||
|
||||
less: {
|
||||
files: ['app/**/*.less'],
|
||||
tasks: ['less:dist']
|
||||
tasks: ['string-replace', 'less:dist']
|
||||
},
|
||||
|
||||
js: {
|
||||
files: ['app/**/*.js'],
|
||||
tasks: ['concat:dist']
|
||||
tasks: ['string-replace', 'concat:dist']
|
||||
},
|
||||
|
||||
html: {
|
||||
files: ['app/**/*.html'],
|
||||
tasks: ['copy:html']
|
||||
tasks: ['string-replace', 'copy:html']
|
||||
},
|
||||
|
||||
dll: {
|
||||
files: ['app/Umbraco/**/*.dll'],
|
||||
tasks: ['copy:dll']
|
||||
},
|
||||
|
||||
assets: {
|
||||
files: ['assets/*.*'],
|
||||
tasks: ['copy:assets']
|
||||
}
|
||||
},
|
||||
|
||||
@@ -41,7 +71,7 @@ module.exports = function(grunt) {
|
||||
paths: ["app/less", "lib/less", "vendor"],
|
||||
},
|
||||
files: {
|
||||
'<%= basePath %>/css/archetype.css': 'app/less/archetype.less',
|
||||
'<%= basePath %>/css/archetype.css': 'app/less/archetype_versioned.less',
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -52,13 +82,22 @@ module.exports = function(grunt) {
|
||||
},
|
||||
dist: {
|
||||
src: [
|
||||
'app/controllers/controller.js',
|
||||
'app/controllers/controller_versioned.js',
|
||||
'app/controllers/config.controller.js',
|
||||
'app/controllers/config.dialog.controller.js',
|
||||
'app/controllers/config.global.controller.js',
|
||||
'app/directives/archetypeproperty.js',
|
||||
'app/directives/archetypesubmitwatcher.js',
|
||||
'app/directives/archetypecustomview.js',
|
||||
'app/directives/localize.js',
|
||||
'app/services/localization.js',
|
||||
'app/resources/propertyeditor.js'
|
||||
'app/directives/archetypeLocalize.js',
|
||||
'app/directives/archetypeclickoutside.js',
|
||||
'app/services/archetypeLocalizationService.js',
|
||||
'app/helpers/sampleLabelHelpers.js',
|
||||
'app/resources/archetypePropertyEditorResource.js',
|
||||
'app/services/archetypeService.js',
|
||||
'app/services/archetypeLabelService.js',
|
||||
'app/services/archetypeCacheService.js',
|
||||
'app/services/archetypeGlobalConfigService.js'
|
||||
],
|
||||
dest: '<%= basePath %>/js/archetype.js'
|
||||
}
|
||||
@@ -67,8 +106,24 @@ module.exports = function(grunt) {
|
||||
copy: {
|
||||
html: {
|
||||
cwd: 'app/views/',
|
||||
src: ['archetype.html', 'archetype.default.html', 'archetype.config.html'],
|
||||
dest: '<%= basePath %>/views',
|
||||
src: [
|
||||
'archetype_versioned.html',
|
||||
'archetype.default_versioned.html',
|
||||
'archetype.config_versioned.html',
|
||||
'archetype.config.fieldset.dialog_versioned.html',
|
||||
'archetype.config.stylescript.dialog_versioned.html',
|
||||
'archetype.config.developer.dialog_versioned.html'
|
||||
],
|
||||
dest: '<%= basePath %>/views/',
|
||||
expand: true,
|
||||
rename: function(dest, src) {
|
||||
return dest + src.replace('_versioned','');
|
||||
}
|
||||
},
|
||||
assets: {
|
||||
cwd: 'assets/',
|
||||
src: ['*.*'],
|
||||
dest: '<%= basePath %>/assets',
|
||||
expand: true
|
||||
},
|
||||
dll: {
|
||||
@@ -98,7 +153,13 @@ module.exports = function(grunt) {
|
||||
{
|
||||
cwd: '<%= dest %>/bin',
|
||||
src: ['*.dll'],
|
||||
dest: 'tmp/nuget/lib/net40',
|
||||
dest: 'tmp/nuget_binaries/lib/net40',
|
||||
expand: true
|
||||
},
|
||||
{
|
||||
cwd: 'app/Umbraco/Archetype.Courier/bin/Release/',
|
||||
src: ['Archetype.Courier.dll'],
|
||||
dest: 'tmp/nuget_courier/lib/net40',
|
||||
expand: true
|
||||
}
|
||||
]
|
||||
@@ -112,60 +173,119 @@ module.exports = function(grunt) {
|
||||
},
|
||||
|
||||
nugetpack: {
|
||||
dist: {
|
||||
src: 'tmp/nuget/package.nuspec',
|
||||
dest: 'pkg'
|
||||
}
|
||||
dist: {
|
||||
src: 'tmp/nuget/package.nuspec',
|
||||
dest: 'pkg'
|
||||
},
|
||||
dist_binaries: {
|
||||
src: 'tmp/nuget_binaries/package_binaries.nuspec',
|
||||
dest: 'pkg'
|
||||
},
|
||||
dist_courier: {
|
||||
src: 'tmp/nuget_courier/package_courier.nuspec',
|
||||
dest: 'pkg'
|
||||
}
|
||||
},
|
||||
|
||||
template: {
|
||||
'nuspec': {
|
||||
'options': {
|
||||
'data': {
|
||||
name: '<%= pkgMeta.name %>',
|
||||
version: '<%= pkgMeta.version %>',
|
||||
url: '<%= pkgMeta.url %>',
|
||||
license: '<%= pkgMeta.license %>',
|
||||
licenseUrl: '<%= pkgMeta.licenseUrl %>',
|
||||
author: '<%= pkgMeta.author %>',
|
||||
authorUrl: '<%= pkgMeta.authorUrl %>',
|
||||
|
||||
files: [{ path: 'tmp/nuget/**', target: 'content/App_Plugins/Archetype'}]
|
||||
}
|
||||
},
|
||||
'files': {
|
||||
'tmp/nuget/package.nuspec': ['config/package.nuspec']
|
||||
}
|
||||
}
|
||||
'nuspec': {
|
||||
'options': {
|
||||
'data': {
|
||||
name: '<%= pkgMeta.name %>',
|
||||
version: '<%= pkgMeta.version %>',
|
||||
url: '<%= pkgMeta.url %>',
|
||||
license: '<%= pkgMeta.license %>',
|
||||
licenseUrl: '<%= pkgMeta.licenseUrl %>',
|
||||
author: '<%= pkgMeta.author %>',
|
||||
authorUrl: '<%= pkgMeta.authorUrl %>'
|
||||
}
|
||||
},
|
||||
'files': {
|
||||
'tmp/nuget/package.nuspec': ['config/package.nuspec']
|
||||
}
|
||||
},
|
||||
'nuspec_binaries': {
|
||||
'options': {
|
||||
'data': {
|
||||
name: '<%= pkgMeta.name %>.Binaries',
|
||||
version: '<%= pkgMeta.version %>',
|
||||
url: '<%= pkgMeta.url %>',
|
||||
license: '<%= pkgMeta.license %>',
|
||||
licenseUrl: '<%= pkgMeta.licenseUrl %>',
|
||||
author: '<%= pkgMeta.author %>',
|
||||
authorUrl: '<%= pkgMeta.authorUrl %>'
|
||||
}
|
||||
},
|
||||
'files': {
|
||||
'tmp/nuget_binaries/package_binaries.nuspec': ['config/package_binaries.nuspec']
|
||||
}
|
||||
},
|
||||
'nuspec_courier': {
|
||||
'options': {
|
||||
'data': {
|
||||
name: '<%= pkgMeta.name %>.Courier',
|
||||
version: '<%= pkgMeta.version %>',
|
||||
url: '<%= pkgMeta.url %>',
|
||||
license: '<%= pkgMeta.license %>',
|
||||
licenseUrl: '<%= pkgMeta.licenseUrl %>',
|
||||
author: '<%= pkgMeta.author %>',
|
||||
authorUrl: '<%= pkgMeta.authorUrl %>'
|
||||
}
|
||||
},
|
||||
'files': {
|
||||
'tmp/nuget_courier/package_courier.nuspec': ['config/package_courier.nuspec']
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
umbracoPackage: {
|
||||
options: {
|
||||
name: "<%= pkgMeta.name %>",
|
||||
version: '<%= pkgMeta.version %>',
|
||||
url: '<%= pkgMeta.url %>',
|
||||
license: '<%= pkgMeta.license %>',
|
||||
licenseUrl: '<%= pkgMeta.licenseUrl %>',
|
||||
author: '<%= pkgMeta.author %>',
|
||||
authorUrl: '<%= pkgMeta.authorUrl %>',
|
||||
manifest: 'config/package.xml',
|
||||
readme: 'config/readme.txt',
|
||||
sourceDir: 'tmp/umbraco',
|
||||
outputDir: 'pkg',
|
||||
dist: {
|
||||
src: 'tmp/umbraco',
|
||||
dest: 'pkg',
|
||||
options: {
|
||||
name: "<%= pkgMeta.name %>",
|
||||
version: '<%= pkgMeta.version %>',
|
||||
url: '<%= pkgMeta.url %>',
|
||||
license: '<%= pkgMeta.license %>',
|
||||
licenseUrl: '<%= pkgMeta.licenseUrl %>',
|
||||
author: '<%= pkgMeta.author %>',
|
||||
authorUrl: '<%= pkgMeta.authorUrl %>',
|
||||
readme: '<%= grunt.file.read("config/readme.txt") %>'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
clean: {
|
||||
build: '<%= grunt.config("basePath").substring(0, 4) == "dist" ? "dist/**/*" : "null" %>',
|
||||
tmp: ['tmp']
|
||||
tmp: ['tmp'],
|
||||
html: [
|
||||
'app/views/*.html',
|
||||
'!app/views/archetype.html',
|
||||
'!app/views/archetype.default.html',
|
||||
'!app/views/archetype.config.html',
|
||||
'!app/views/archetype.config.fieldset.dialog.html',
|
||||
'!app/views/archetype.config.stylescript.dialog.html',
|
||||
'!app/views/archetype.config.developer.dialog.html'
|
||||
],
|
||||
js: [
|
||||
'app/controllers/*.js',
|
||||
'!app/controllers/controller.js',
|
||||
'!app/controllers/config.controller.js',
|
||||
'!app/controllers/config.dialog.controller.js',
|
||||
'!app/controllers/config.global.controller.js'
|
||||
],
|
||||
less: [
|
||||
'app/less/*.less',
|
||||
'!app/less/archetype.less'
|
||||
]
|
||||
},
|
||||
|
||||
assemblyinfo: {
|
||||
options: {
|
||||
files: ['app/Umbraco/Umbraco.Archetype/Archetype.Umbraco.csproj'],
|
||||
files: ['app/Umbraco/Umbraco.Archetype/Archetype.Umbraco.csproj', 'app/Umbraco/Archetype.Courier/Archetype.Courier.csproj'],
|
||||
filename: 'VersionInfo.cs',
|
||||
info: {
|
||||
version: '<%= (pkgMeta.version.indexOf("-") ? pkgMeta.version.substring(0, pkgMeta.version.indexOf("-")) : pkgMeta.version) %>',
|
||||
version: '<%= (pkgMeta.version.indexOf("-") > 0 ? pkgMeta.version.substring(0, pkgMeta.version.indexOf("-")) : pkgMeta.version) %>',
|
||||
fileVersion: '<%= pkgMeta.version %>'
|
||||
}
|
||||
}
|
||||
@@ -177,40 +297,29 @@ module.exports = function(grunt) {
|
||||
}
|
||||
},
|
||||
|
||||
jshint: {
|
||||
options: {
|
||||
jshintrc: '.jshintrc'
|
||||
},
|
||||
src: {
|
||||
src: ['app/**/*.js', 'lib/**/*.js']
|
||||
}
|
||||
},
|
||||
|
||||
msbuild: {
|
||||
options: {
|
||||
stdout: true,
|
||||
verbosity: 'quiet',
|
||||
maxCpuCount: 4,
|
||||
version: 4.0,
|
||||
version: 4.0,
|
||||
buildParameters: {
|
||||
WarningLevel: 2,
|
||||
NoWarn: 1607
|
||||
}
|
||||
},
|
||||
dist: {
|
||||
src: ['app/Umbraco/Umbraco.Archetype/Archetype.Umbraco.csproj'],
|
||||
src: ['app/Umbraco/Umbraco.Archetype/Archetype.Umbraco.csproj','app/Umbraco/Archetype.Courier/Archetype.Courier.csproj'],
|
||||
options: {
|
||||
projectConfiguration: 'Release',
|
||||
targets: ['Clean', 'Rebuild'],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
grunt.registerTask('default', ['clean', 'less', 'concat', 'assemblyinfo', 'msbuild:dist', 'copy:dll', 'copy:config', 'copy:html']);
|
||||
|
||||
grunt.registerTask('nuget', ['clean:tmp', 'default', 'copy:nuget', 'template:nuspec', 'nugetpack', 'clean:tmp']);
|
||||
grunt.registerTask('umbraco', ['clean:tmp', 'default', 'copy:umbraco', 'umbracoPackage', 'clean:tmp']);
|
||||
grunt.registerTask('package', ['clean:tmp', 'default', 'copy:nuget', 'template:nuspec', 'nugetpack', 'copy:umbraco', 'umbracoPackage', 'clean:tmp']);
|
||||
grunt.registerTask('default', ['clean', 'string-replace', 'less', 'concat', 'assemblyinfo', 'msbuild:dist', 'copy:dll', 'copy:assets', 'copy:html', 'copy:config', 'clean:html', 'clean:js', 'clean:less']);
|
||||
grunt.registerTask('nuget', ['copy:nuget', 'template:nuspec', 'template:nuspec_binaries', 'template:nuspec_courier', 'nugetpack']);
|
||||
grunt.registerTask('umbraco', ['copy:umbraco', 'umbracoPackage']);
|
||||
grunt.registerTask('package', ['clean:tmp', 'default', 'nuget', 'copy:umbraco', 'umbracoPackage', 'clean:tmp']);
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Imulus
|
||||
Copyright (c) 2016 Kevin Giszewski LLC
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
||||
@@ -7,12 +7,26 @@ Archetype
|
||||
## Installation
|
||||
Install the selected <a href='https://github.com/imulus/Archetype/releases'>release</a> through the Umbraco package installer or via <a href='http://www.nuget.org/packages/Archetype/'>NuGet</a>.
|
||||
|
||||
|
||||
## Official Docs ##
|
||||
http://imulus.github.io/Archetype
|
||||
https://github.com/kgiszewski/ArchetypeManual
|
||||
|
||||
Get up and running in 15 minutes! https://www.youtube.com/watch?v=79LksNwGjLk
|
||||
|
||||
## News and Updates ##
|
||||
Follow us on Twitter https://twitter.com/ArchetypeKit
|
||||
|
||||
## Core Team ##
|
||||
* Kevin Giszewski (founder/project lead) - University of Notre Dame - https://kevin.giszewski.com/
|
||||
* Tom Fulton (founder) - Tonic - http://hellotonic.com/
|
||||
* Lee Kelleher - Umbrella - http://www.umbrellainc.co.uk/
|
||||
* Matt Brailsford - The Outfield - http://www.theoutfield.co.uk/
|
||||
* Kenn Jacobsen - Vertica - http://kennjacobsen.dk/
|
||||
|
||||
## Donate!
|
||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KBKWLURGLGU6L)
|
||||
|
||||
This project is funded by the core team members' time only. We don't charge for Archetype but it does take quite a bit of effort to keep it up-to-date with Umbraco core changes. If you're making a few bucks off of Archetype, we wouldn't refuse a donation :)
|
||||
|
||||
## Contribute ##
|
||||
|
||||
Want to contribute to Archetype? You'll want to use Grunt (our task runner) to help you integrate with a local copy of Umbraco.
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{FE8BE437-8B11-4E49-9B02-F45994E6D723}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Archetype.Courier</RootNamespace>
|
||||
<AssemblyName>Archetype.Courier</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="businesslogic">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\businesslogic.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="cms">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\cms.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="interfaces">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\interfaces.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="log4net">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\log4net.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\packages\Newtonsoft.Json.6.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="umbraco">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\umbraco.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Umbraco.Core">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\Umbraco.Core.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Umbraco.Courier.Core">
|
||||
<HintPath>lib\Umbraco.Courier.Core.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Umbraco.Courier.DataResolvers">
|
||||
<HintPath>lib\Umbraco.Courier.DataResolvers.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Umbraco.Courier.Providers">
|
||||
<HintPath>lib\Umbraco.Courier.Providers.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="umbraco.providers">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\umbraco.providers.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Umbraco.Archetype\Properties\VersionInfo.cs">
|
||||
<Link>Properties\VersionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="DataResolvers\ArchetypeDataResolver.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Umbraco.Archetype\Archetype.Umbraco.csproj">
|
||||
<Project>{7d185d41-4228-4978-acb8-83f9a48ad94f}</Project>
|
||||
<Name>Archetype.Umbraco</Name>
|
||||
<Private>True</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,260 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Archetype.Extensions;
|
||||
using Archetype.Models;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Courier.Core;
|
||||
using Umbraco.Courier.Core.Logging;
|
||||
using Umbraco.Courier.Core.ProviderModel;
|
||||
using Umbraco.Courier.DataResolvers;
|
||||
using Umbraco.Courier.ItemProviders;
|
||||
|
||||
namespace Archetype.Courier.DataResolvers
|
||||
{
|
||||
/// <summary>
|
||||
/// Lee Kelleher's implementation of Courier's PropertyDataResolverProvider for Archetype.
|
||||
/// </summary>
|
||||
public class ArchetypeDataResolver : PropertyDataResolverProvider
|
||||
{
|
||||
private enum Direction
|
||||
{
|
||||
Extracting,
|
||||
Packaging
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the editor alias.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The editor alias.
|
||||
/// </value>
|
||||
public override string EditorAlias
|
||||
{
|
||||
get
|
||||
{
|
||||
return Constants.PropertyEditorAlias;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extractings the type of the data.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
public override void ExtractingDataType(DataType item)
|
||||
{
|
||||
// No longer need to extract the DataType (int) Ids as Archetype now references the Guid [LK]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extractings the property.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="propertyData">The property data.</param>
|
||||
public override void ExtractingProperty(Item item, ContentProperty propertyData)
|
||||
{
|
||||
ReplacePropertyDataIds(item, propertyData, Direction.Extracting);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Packagings the type of the data.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
public override void PackagingDataType(DataType item)
|
||||
{
|
||||
AddDataTypeDependencies(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Packages the property.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="propertyData">The property data.</param>
|
||||
public override void PackagingProperty(Item item, ContentProperty propertyData)
|
||||
{
|
||||
ReplacePropertyDataIds(item, propertyData, Direction.Packaging);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the datatype dependencies.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
private void AddDataTypeDependencies(DataType item)
|
||||
{
|
||||
if (item.Prevalues != null && item.Prevalues.Count > 0)
|
||||
{
|
||||
var prevalue = item.Prevalues[0];
|
||||
if (prevalue.Alias.InvariantEquals(Constants.PreValueAlias) && !string.IsNullOrWhiteSpace(prevalue.Value))
|
||||
{
|
||||
var config = JsonConvert.DeserializeObject<ArchetypePreValue>(prevalue.Value);
|
||||
|
||||
if (config != null && config.Fieldsets != null)
|
||||
{
|
||||
foreach (var property in config.Fieldsets.SelectMany(x => x.Properties))
|
||||
{
|
||||
item.Dependencies.Add(property.DataTypeGuid.ToString(), ItemProviderIds.dataTypeItemProviderGuid);
|
||||
}
|
||||
|
||||
item.Prevalues[0].Value = JsonConvert.SerializeObject(config, Formatting.None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces the property data Ids.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="propertyData">The property data.</param>
|
||||
/// <param name="direction">The direction.</param>
|
||||
private void ReplacePropertyDataIds(Item item, ContentProperty propertyData, Direction direction)
|
||||
{
|
||||
if (propertyData != null && propertyData.Value != null)
|
||||
{
|
||||
var dataType = ExecutionContext.DatabasePersistence.RetrieveItem<DataType>(new ItemIdentifier(propertyData.DataType.ToString(),
|
||||
ItemProviderIds.dataTypeItemProviderGuid));
|
||||
|
||||
//Fetch the Prevalues for the current Property's DataType (if its an 'Archetype config')
|
||||
var prevalue = dataType.Prevalues.FirstOrDefault(x => x.Alias.ToLowerInvariant().Equals("archetypeconfig"));
|
||||
var archetypePreValue = prevalue == null
|
||||
? null
|
||||
: JsonConvert.DeserializeObject<ArchetypePreValue>(prevalue.Value,
|
||||
ArchetypeHelper.Instance.JsonSerializerSettings);
|
||||
RetrieveAdditionalProperties(ref archetypePreValue);
|
||||
|
||||
//Deserialize the value of the current Property to an ArchetypeModel and set additional properties before converting values
|
||||
var sourceJson = propertyData.Value.ToString();
|
||||
var archetype = JsonConvert.DeserializeObject<ArchetypeModel>(sourceJson, ArchetypeHelper.Instance.JsonSerializerSettings);
|
||||
RetrieveAdditionalProperties(ref archetype, archetypePreValue);
|
||||
|
||||
if (archetype != null)
|
||||
{
|
||||
// get the `PropertyItemProvider` from the collection.
|
||||
var propertyItemProvider = ItemProviderCollection.Instance.GetProvider(ItemProviderIds.propertyDataItemProviderGuid, ExecutionContext);
|
||||
|
||||
foreach (var property in archetype.Fieldsets.SelectMany(x => x.Properties))
|
||||
{
|
||||
if (property == null || string.IsNullOrWhiteSpace(property.PropertyEditorAlias))
|
||||
continue;
|
||||
|
||||
// create a 'fake' item for Courier to process
|
||||
var fakeItem = new ContentPropertyData
|
||||
{
|
||||
ItemId = item.ItemId,
|
||||
Name = string.Format("{0} [{1}: Nested {2} ({3})]", new[] { item.Name, EditorAlias, property.PropertyEditorAlias, property.Alias }),
|
||||
Data = new List<ContentProperty>
|
||||
{
|
||||
new ContentProperty
|
||||
{
|
||||
Alias = property.Alias,
|
||||
DataType = ExecutionContext.DatabasePersistence.GetUniqueId(property.DataTypeId, UmbracoNodeObjectTypeIds.DataType),
|
||||
PropertyEditorAlias = property.PropertyEditorAlias,
|
||||
Value = property.Value
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (direction == Direction.Packaging)
|
||||
{
|
||||
try
|
||||
{
|
||||
// run the 'fake' item through Courier's data resolvers
|
||||
ResolutionManager.Instance.PackagingItem(fakeItem, propertyItemProvider);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
CourierLogHelper.Error<ArchetypeDataResolver>(string.Concat("Error packaging data value: ", fakeItem.Name), ex);
|
||||
}
|
||||
|
||||
// pass up the dependencies and resources
|
||||
item.Dependencies.AddRange(fakeItem.Dependencies);
|
||||
item.Resources.AddRange(fakeItem.Resources);
|
||||
}
|
||||
else if (direction == Direction.Extracting)
|
||||
{
|
||||
try
|
||||
{
|
||||
// run the 'fake' item through Courier's data resolvers
|
||||
ResolutionManager.Instance.ExtractingItem(fakeItem, propertyItemProvider);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
CourierLogHelper.Error<ArchetypeDataResolver>(string.Concat("Error extracting data value: ", fakeItem.Name), ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (fakeItem.Data != null && fakeItem.Data.Any())
|
||||
{
|
||||
var firstDataType = fakeItem.Data.FirstOrDefault();
|
||||
if (firstDataType != null)
|
||||
{
|
||||
// set the resolved property data value
|
||||
property.Value = firstDataType.Value;
|
||||
|
||||
// (if packaging) add a dependency for the property's data-type
|
||||
if (direction == Direction.Packaging)
|
||||
item.Dependencies.Add(firstDataType.DataType.ToString(), ItemProviderIds.dataTypeItemProviderGuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// serialize the Archetype back to a string
|
||||
propertyData.Value = archetype.SerializeForPersistence();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the additional properties.
|
||||
/// </summary>
|
||||
/// <param name="preValue">The pre value.</param>
|
||||
private void RetrieveAdditionalProperties(ref ArchetypePreValue preValue)
|
||||
{
|
||||
if (preValue == null)
|
||||
return;
|
||||
|
||||
foreach (var fieldset in preValue.Fieldsets)
|
||||
{
|
||||
foreach (var property in fieldset.Properties)
|
||||
{
|
||||
var dataType = ExecutionContext.DatabasePersistence.RetrieveItem<DataType>(
|
||||
new ItemIdentifier(property.DataTypeGuid.ToString(),
|
||||
ItemProviderIds.dataTypeItemProviderGuid));
|
||||
|
||||
if (dataType == null)
|
||||
continue;
|
||||
|
||||
property.PropertyEditorAlias = dataType.PropertyEditorAlias;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the additional properties.
|
||||
/// </summary>
|
||||
/// <param name="archetype">The archetype.</param>
|
||||
/// <param name="preValue">The pre value.</param>
|
||||
private void RetrieveAdditionalProperties(ref ArchetypeModel archetype, ArchetypePreValue preValue)
|
||||
{
|
||||
foreach (var fieldset in preValue.Fieldsets)
|
||||
{
|
||||
var fieldsetAlias = fieldset.Alias;
|
||||
foreach (var fieldsetInst in archetype.Fieldsets.Where(x => x.Alias == fieldsetAlias))
|
||||
{
|
||||
foreach (var property in fieldset.Properties)
|
||||
{
|
||||
var propertyAlias = property.Alias;
|
||||
foreach (var propertyInst in fieldsetInst.Properties.Where(x => x.Alias == propertyAlias))
|
||||
{
|
||||
propertyInst.DataTypeGuid = property.DataTypeGuid.ToString();
|
||||
propertyInst.DataTypeId = ExecutionContext.DatabasePersistence.GetNodeId(
|
||||
property.DataTypeGuid, UmbracoNodeObjectTypeIds.DataType);
|
||||
propertyInst.PropertyEditorAlias = property.PropertyEditorAlias;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("Archetype.Courier")]
|
||||
[assembly: AssemblyDescription("A set of tools to support Archetype with Umbraco Courier")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Umbrella Inc Ltd")]
|
||||
[assembly: AssemblyProduct("Archetype.Courier")]
|
||||
[assembly: AssemblyCopyright("Copyright \xa9 Lee Kelleher, Umbrella Inc Ltd 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("6F05C431-ABBF-4D77-9D3D-5AF6C8E318AF")]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
+2
-2
@@ -4,8 +4,8 @@
|
||||
<package id="ClientDependency" version="1.7.1.2" targetFramework="net45" />
|
||||
<package id="ClientDependency-Mvc" version="1.7.0.4" targetFramework="net45" />
|
||||
<package id="HtmlAgilityPack" version="1.4.6" targetFramework="net45" />
|
||||
<package id="ImageProcessor" version="1.9.0.0" targetFramework="net45" />
|
||||
<package id="ImageProcessor.Web" version="3.2.3.0" targetFramework="net45" />
|
||||
<package id="ImageProcessor" version="1.8.7.0" targetFramework="net45" />
|
||||
<package id="ImageProcessor.Web" version="3.2.1.0" targetFramework="net45" />
|
||||
<package id="Lucene.Net" version="2.9.4.1" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.Mvc" version="4.0.20710.0" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.Mvc.FixedDisplayModes" version="1.0.0" targetFramework="net45" />
|
||||
@@ -33,67 +33,85 @@
|
||||
<ItemGroup>
|
||||
<Reference Include="AutoMapper">
|
||||
<HintPath>..\packages\AutoMapper.3.0.0\lib\net40\AutoMapper.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="AutoMapper.Net4">
|
||||
<HintPath>..\packages\AutoMapper.3.0.0\lib\net40\AutoMapper.Net4.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="businesslogic, Version=1.0.5242.22740, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\businesslogic.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="ClientDependency.Core">
|
||||
<HintPath>..\packages\ClientDependency.1.7.1.2\lib\ClientDependency.Core.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="ClientDependency.Core.Mvc">
|
||||
<HintPath>..\packages\ClientDependency-Mvc.1.7.0.4\lib\ClientDependency.Core.Mvc.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="cms, Version=1.0.5242.22741, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\cms.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="controls, Version=1.0.5242.22742, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\controls.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="CookComputing.XmlRpcV2">
|
||||
<HintPath>..\packages\xmlrpcnet.2.5.0\lib\net20\CookComputing.XmlRpcV2.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Examine, Version=0.1.55.2941, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\Examine.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="HtmlAgilityPack">
|
||||
<HintPath>..\packages\HtmlAgilityPack.1.4.6\lib\Net45\HtmlAgilityPack.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="ICSharpCode.SharpZipLib">
|
||||
<HintPath>..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="ImageProcessor, Version=1.9.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\ImageProcessor.1.9.0.0\lib\ImageProcessor.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="ImageProcessor.Web, Version=3.2.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\ImageProcessor.Web.3.2.3.0\lib\net45\ImageProcessor.Web.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="interfaces, Version=1.0.5242.22737, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\interfaces.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="log4net, Version=1.2.11.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\log4net.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Lucene.Net">
|
||||
<HintPath>..\packages\Lucene.Net.2.9.4.1\lib\net40\Lucene.Net.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ApplicationBlocks.Data, Version=1.0.1559.20655, Culture=neutral">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\Microsoft.ApplicationBlocks.Data.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\Microsoft.Web.Helpers.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
@@ -101,26 +119,33 @@
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Mvc.FixedDisplayModes">
|
||||
<HintPath>..\packages\Microsoft.AspNet.Mvc.FixedDisplayModes.1.0.1\lib\net40\Microsoft.Web.Mvc.FixedDisplayModes.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="MiniProfiler">
|
||||
<HintPath>..\packages\MiniProfiler.2.1.0\lib\net40\MiniProfiler.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Moq">
|
||||
<HintPath>..\packages\Moq.4.2.1312.1622\lib\net40\Moq.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="MySql.Data">
|
||||
<HintPath>..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Newtonsoft.Json.6.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
|
||||
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="SQLCE4Umbraco, Version=1.0.5242.22741, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\SQLCE4Umbraco.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
@@ -135,17 +160,21 @@
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.4.0.30506.0\lib\net40\System.Net.Http.Formatting.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.WebRequest" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.Helpers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.4.0.30506.0\lib\net40\System.Web.Http.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebApi.WebHost.4.0.30506.0\lib\net40\System.Web.Http.WebHost.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
@@ -176,84 +205,81 @@
|
||||
<Reference Include="TidyNet, Version=1.0.0.0, Culture=neutral">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\TidyNet.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="umbraco, Version=1.0.5242.22743, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\umbraco.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Umbraco.Core, Version=1.0.5242.22738, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\Umbraco.Core.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="umbraco.DataLayer, Version=1.0.5242.22740, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\umbraco.DataLayer.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="umbraco.editorControls, Version=1.0.5242.22746, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\umbraco.editorControls.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="umbraco.MacroEngines, Version=1.0.5242.22747, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\umbraco.MacroEngines.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="umbraco.providers, Version=1.0.5242.22742, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\umbraco.providers.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Umbraco.Web.UI, Version=1.0.5242.22748, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\Umbraco.Web.UI.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="umbraco.XmlSerializers, Version=1.0.5242.22743, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\umbraco.XmlSerializers.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="UmbracoExamine, Version=0.6.0.22741, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\UmbracoExamine.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="UrlRewritingNet.UrlRewriter, Version=2.0.60829.1, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\UrlRewritingNet.UrlRewriter.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Models\FieldsetTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="PropertyValueConverter\PropertyValueConverterTests.cs" />
|
||||
<Compile Include="Serialization\Base\ArchetypeJsonConverterTestBase.cs" />
|
||||
<Compile Include="Serialization\Base\RegressionTestBase.cs" />
|
||||
<Compile Include="Serialization\Delinter\ArchetypeJsonDelinterTest.cs" />
|
||||
<Compile Include="Serialization\Regression\ArchetypeJsonConverterLegacySetUpTest.cs" />
|
||||
<Compile Include="Serialization\Regression\ArchetypeJsonConverterTest.cs" />
|
||||
<Compile Include="Serialization\Regression\JsonTestLegacyModelSetUp.cs" />
|
||||
<Compile Include="Serialization\Regression\SerializationTestHelper.cs" />
|
||||
<Compile Include="Serialization\Regression\JsonTestModels.cs" />
|
||||
<Compile Include="Serialization\Regression\JsonTestStrings.cs" />
|
||||
<Compile Include="Serialization\UseCases\ArchetypeJsonConverterTest.cs" />
|
||||
<Compile Include="Serialization\UseCases\Complex\ArchetypeJsonConverterTest.cs" />
|
||||
<Compile Include="Serialization\UseCases\Complex\JsonTestModels.cs" />
|
||||
<Compile Include="Serialization\UseCases\Complex\JsonTestStrings.cs" />
|
||||
<Compile Include="Serialization\UseCases\Enumerable\ArchetypeJsonConverterTest.cs" />
|
||||
<Compile Include="Serialization\UseCases\Enumerable\JsonTestModels.cs" />
|
||||
<Compile Include="Serialization\UseCases\Enumerable\JsonTestStrings.cs" />
|
||||
<Compile Include="Serialization\UseCases\JsonTestModels.cs" />
|
||||
<Compile Include="Serialization\UseCases\JsonTestStrings.cs" />
|
||||
<Compile Include="PublishedContent\ArchetypePublishedContentTests.cs" />
|
||||
<Compile Include="PublishedContent\TypeConverterTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="Data\sample-1.json" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="SupportingFiles\config\umbracoSettings.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Umbraco.Archetype\Archetype.Umbraco.csproj">
|
||||
<Project>{7D185D41-4228-4978-ACB8-83F9A48AD94F}</Project>
|
||||
<Name>Archetype.Umbraco</Name>
|
||||
<Private>True</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||
<PropertyGroup>
|
||||
@@ -261,7 +287,8 @@
|
||||
</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>xcopy $(ProjectDir)SupportingFiles\config\* $(TargetDir)config /I /O /X /E /K /D /Y</PostBuildEvent>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Archetype.PropertyConverters;
|
||||
using Archetype.Tests.Serialization.UseCases;
|
||||
using NUnit.Framework;
|
||||
using Archetype.Tests.Serialization;
|
||||
|
||||
namespace Archetype.Tests.Models
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Tests designed for the fieldsets.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class FieldsetTests
|
||||
{
|
||||
|
||||
private string _sampleJson;
|
||||
|
||||
/// <summary>
|
||||
/// Sets up the test to use sample JSON data.
|
||||
/// </summary>
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
@@ -59,25 +57,7 @@ namespace Archetype.Tests.Models
|
||||
Assert.That(fieldset.GetValue<int>("link") == 3175);
|
||||
Assert.That(fieldset.GetValue<bool>("show") == true);
|
||||
Assert.That(fieldset.GetValue<string>("blurb") == "A blurb here");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Convert_Property_Default_Value_Types()
|
||||
{
|
||||
var converter = new ArchetypeValueConverter();
|
||||
var result = (Archetype.Models.ArchetypeModel)converter.ConvertDataToSource(null, _sampleJson, false);
|
||||
|
||||
var fieldset = result.Fieldsets.First();
|
||||
|
||||
Assert.That(fieldset.GetValue<int>("noSuchInteger", 1234) == 1234);
|
||||
Assert.That(fieldset.GetValue<bool>("noSuchBoolean", true) == true);
|
||||
Assert.That(fieldset.GetValue<bool>("noSuchBoolean", false) == false);
|
||||
Assert.That(fieldset.GetValue<string>("noSuchString", "noSuchString default value") == "noSuchString default value");
|
||||
|
||||
var contactDetails = fieldset.GetValue<ContactDetails>("noSuchContact", new ContactDetails { Address = "some street, some city", Name = "someone" });
|
||||
Assert.That(contactDetails.Address == "some street, some city");
|
||||
Assert.That(contactDetails.Name == "someone");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Returns_String_When_No_Type_Specified()
|
||||
@@ -91,6 +71,5 @@ namespace Archetype.Tests.Models
|
||||
Assert.That(property is string);
|
||||
Assert.That(property == "3175");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Archetype.PropertyConverters;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
|
||||
namespace Archetype.Tests.PropertyValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests designed to test the PVC.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class PropertyValueConverterTests
|
||||
{
|
||||
|
||||
private string _sampleJson;
|
||||
|
||||
/// <summary>
|
||||
/// Sets up the test to use JSON data.
|
||||
/// </summary>
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Archetype.Extensions;
|
||||
using Archetype.Models;
|
||||
using Archetype.PropertyConverters;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web;
|
||||
|
||||
namespace Archetype.Tests.PublishedContent
|
||||
{
|
||||
[TestFixture]
|
||||
public class ArchetypePublishedContentTests
|
||||
{
|
||||
private ArchetypeModel _archetype;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
{
|
||||
var archetypeJson = System.IO.File.ReadAllText("..\\..\\Data\\sample-1.json");
|
||||
var converter = new ArchetypeValueConverter();
|
||||
|
||||
_archetype = (ArchetypeModel)converter.ConvertDataToSource(null, archetypeJson, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ArchetypeModel_Initialized()
|
||||
{
|
||||
Assert.IsNotNull(_archetype);
|
||||
Assert.IsNotEmpty(_archetype.Fieldsets);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ArchetypeModel_To_PublishedContentSet()
|
||||
{
|
||||
var contentSet = _archetype.ToPublishedContentSet();
|
||||
|
||||
Assert.That(contentSet, Is.Not.Null);
|
||||
Assert.That(contentSet, Is.Not.Empty);
|
||||
Assert.That(contentSet, Is.All.InstanceOf<IPublishedContent>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ArchetypeFieldsetModel_To_PublishedContent()
|
||||
{
|
||||
var fieldset = _archetype.Fieldsets.FirstOrDefault();
|
||||
var content = fieldset.ToPublishedContent();
|
||||
|
||||
Assert.That(content, Is.Not.Null);
|
||||
Assert.That(content, Is.InstanceOf<IPublishedContent>());
|
||||
Assert.That(content.Properties, Is.Not.Empty);
|
||||
Assert.That(content.Properties, Is.All.InstanceOf<IPublishedProperty>());
|
||||
}
|
||||
|
||||
[TestCase("boxHeadline", "Box 1 Title")]
|
||||
[TestCase("link", "3175")]
|
||||
[TestCase("link", 3175)]
|
||||
[TestCase("show", "1")]
|
||||
[TestCase("show", true)]
|
||||
[TestCase("show", 1)]
|
||||
public void ArchetypePublishedContent_Typed_Properties<T>(string propertyAlias, T expected)
|
||||
{
|
||||
var fieldset = _archetype.Fieldsets.FirstOrDefault();
|
||||
var content = fieldset.ToPublishedContent();
|
||||
|
||||
var actual = content.GetPropertyValue<T>(propertyAlias);
|
||||
|
||||
Assert.AreEqual(actual, expected);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Null_ArchetypeModel_Throws_Exception()
|
||||
{
|
||||
TestDelegate code = () =>
|
||||
{
|
||||
ArchetypeModel archetype = null;
|
||||
archetype.ToPublishedContentSet();
|
||||
};
|
||||
|
||||
Assert.Throws<ArgumentNullException>(code);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Null_ArchetypeFieldsetModel_Throws_Exception()
|
||||
{
|
||||
TestDelegate code = () =>
|
||||
{
|
||||
ArchetypeFieldsetModel fieldset = null;
|
||||
fieldset.ToPublishedContent();
|
||||
};
|
||||
|
||||
Assert.Throws<ArgumentNullException>(code);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ArchetypePublishedContent_GetIndex()
|
||||
{
|
||||
var contentSet = _archetype.ToPublishedContentSet();
|
||||
var i = 0;
|
||||
|
||||
foreach (var content in contentSet)
|
||||
{
|
||||
Assert.AreEqual(content.GetIndex(), i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ArchetypePublishedContentSet_IsFirstIsLast()
|
||||
{
|
||||
var contentSet = _archetype.ToPublishedContentSet();
|
||||
|
||||
foreach (var content in contentSet)
|
||||
{
|
||||
var value = content.GetPropertyValue<string>("boxHeadline");
|
||||
|
||||
Assert.That(value == "Box 1 Title", Is.EqualTo(content.IsFirst()));
|
||||
Assert.That(value == "Another Box", Is.EqualTo(content.IsLast()));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ArchetypePublishedContentSet_PreviousNext()
|
||||
{
|
||||
var contentSet = _archetype.ToPublishedContentSet();
|
||||
var list = contentSet.ToList();
|
||||
|
||||
Assert.That(list.Count, Is.EqualTo(2));
|
||||
|
||||
var first = list[0];
|
||||
var last = list[1];
|
||||
|
||||
var next = first.Next();
|
||||
Assert.AreEqual(next, last);
|
||||
|
||||
var prev = last.Previous();
|
||||
Assert.AreEqual(prev, first);
|
||||
}
|
||||
|
||||
[Test, ExpectedException(typeof(NullReferenceException))]
|
||||
public void ArchetypePublishedContentSet_Siblings()
|
||||
{
|
||||
var contentSet = _archetype.ToPublishedContentSet();
|
||||
var content = contentSet.FirstOrDefault();
|
||||
|
||||
var siblings = content.Siblings();
|
||||
Assert.That(siblings, Is.Not.Null);
|
||||
|
||||
var following = content.FollowingSibling();
|
||||
Assert.That(following, Is.Not.Null);
|
||||
|
||||
var preceding = content.PrecedingSibling();
|
||||
Assert.That(preceding, Is.Not.Null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Archetype.Models;
|
||||
using Archetype.PropertyConverters;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Archetype.Tests.PublishedContent
|
||||
{
|
||||
[TestFixture]
|
||||
public class TypeConverterTests
|
||||
{
|
||||
private ArchetypeModel _archetype;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
{
|
||||
var archetypeJson = System.IO.File.ReadAllText("..\\..\\Data\\sample-1.json");
|
||||
var converter = new ArchetypeValueConverter();
|
||||
|
||||
_archetype = (ArchetypeModel)converter.ConvertDataToSource(null, archetypeJson, false);
|
||||
}
|
||||
|
||||
[TestCase(typeof(ArchetypeModel), true)]
|
||||
[TestCase(typeof(ArchetypePublishedContentSet), true)]
|
||||
[TestCase(typeof(IEnumerable<IPublishedContent>), true)]
|
||||
[TestCase(typeof(string), true)]
|
||||
[TestCase(typeof(int), false)]
|
||||
[TestCase(typeof(ArchetypeFieldsetModel), false)]
|
||||
public void ArchetypeModel_ConvertsTo_EnumerablePublishedContent(Type destinationType, bool expected)
|
||||
{
|
||||
Assert.IsNotNull(_archetype);
|
||||
|
||||
var attempt = _archetype.TryConvertTo(destinationType);
|
||||
|
||||
Assert.That(attempt.Success, Is.EqualTo(expected));
|
||||
|
||||
if (attempt.Success)
|
||||
{
|
||||
Assert.IsNotNull(attempt.Result);
|
||||
Assert.That(attempt.Result, Is.InstanceOf(destinationType));
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase(typeof(ArchetypeFieldsetModel), true)]
|
||||
[TestCase(typeof(ArchetypePublishedContent), true)]
|
||||
[TestCase(typeof(IPublishedContent), true)]
|
||||
[TestCase(typeof(string), true)]
|
||||
[TestCase(typeof(int), false)]
|
||||
[TestCase(typeof(ArchetypeModel), false)]
|
||||
public void ArchetypeFieldsetModel_ConvertsTo_PublishedContent(Type destinationType, bool expected)
|
||||
{
|
||||
CollectionAssert.IsNotEmpty(_archetype.Fieldsets);
|
||||
|
||||
var attempt = _archetype.First().TryConvertTo(destinationType);
|
||||
|
||||
Assert.That(attempt.Success, Is.EqualTo(expected));
|
||||
|
||||
if (attempt.Success)
|
||||
{
|
||||
Assert.IsNotNull(attempt.Result);
|
||||
Assert.That(attempt.Result, Is.InstanceOf(destinationType));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
using Archetype.PropertyConverters;
|
||||
using at = Archetype.Models;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Archetype.Tests.Serialization.Base
|
||||
{
|
||||
public abstract class ArchetypeJsonConverterTestBase
|
||||
{
|
||||
public at.ArchetypeModel ConvertModelToArchetype<T>(T model)
|
||||
{
|
||||
var converter = new ArchetypeValueConverter();
|
||||
var json = JsonConvert.SerializeObject(model);
|
||||
var archetype = (at.ArchetypeModel)converter.ConvertDataToSource(null, json, false);
|
||||
return archetype;
|
||||
}
|
||||
|
||||
public string ConvertModelToArchetypeJson<T>(T model, Formatting formatting = Formatting.None)
|
||||
{
|
||||
return JsonConvert.SerializeObject(model, formatting);
|
||||
}
|
||||
|
||||
public T ConvertArchetypeJsonToModel<T>(string json)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(json);
|
||||
}
|
||||
|
||||
public T ConvertModelToArchetypeAndBack<T>(T model)
|
||||
{
|
||||
var json = ConvertModelToArchetypeJson(model);
|
||||
return ConvertArchetypeJsonToModel<T>(json);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Archetype.Serialization;
|
||||
using Moq;
|
||||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Archetype.Tests.Serialization.Base
|
||||
{
|
||||
public abstract class RegressionTestBase : ArchetypeJsonConverterTestBase
|
||||
{
|
||||
protected void SimpleModel_Regression_Battery<T>(T model)
|
||||
{
|
||||
var archetype = ConvertModelToArchetype(model);
|
||||
Assert.IsNotNull(archetype);
|
||||
|
||||
var archetypeJson = archetype.SerializeForPersistence();
|
||||
var modelJson = ConvertModelToArchetypeJson(model, Formatting.Indented);
|
||||
|
||||
Assert.IsNotNullOrEmpty(modelJson);
|
||||
|
||||
var result = ConvertModelToArchetypeAndBack(model);
|
||||
var resultfromArchetypeJson = ConvertArchetypeJsonToModel<T>(archetypeJson);
|
||||
|
||||
Assert.IsInstanceOf<T>(result);
|
||||
Assert.IsInstanceOf<T>(resultfromArchetypeJson);
|
||||
AssertAreEqual(model, result);
|
||||
AssertAreEqual(model, resultfromArchetypeJson);
|
||||
}
|
||||
|
||||
protected void SimpleModels_Regression_Battery<T>(T model)
|
||||
where T : IList
|
||||
{
|
||||
var archetype = ConvertModelToArchetype(model);
|
||||
Assert.IsNotNull(archetype);
|
||||
|
||||
var archetypeJson = archetype.SerializeForPersistence();
|
||||
var modelJson = ConvertModelToArchetypeJson(model, Formatting.Indented);
|
||||
|
||||
Assert.IsNotNullOrEmpty(modelJson);
|
||||
|
||||
var result = ConvertModelToArchetypeAndBack(model);
|
||||
var resultfromArchetypeJson = ConvertArchetypeJsonToModel<T>(archetypeJson);
|
||||
|
||||
Assert.IsInstanceOf<T>(result);
|
||||
Assert.IsInstanceOf<T>(resultfromArchetypeJson);
|
||||
|
||||
Assert.AreEqual(model.Count, result.Count);
|
||||
Assert.AreEqual(model.Count, resultfromArchetypeJson.Count);
|
||||
|
||||
foreach (var resultItem in result)
|
||||
{
|
||||
var index = result.IndexOf(resultItem);
|
||||
AssertAreEqual(model[index], resultItem);
|
||||
}
|
||||
|
||||
foreach (var resultItem in resultfromArchetypeJson)
|
||||
{
|
||||
var index = resultfromArchetypeJson.IndexOf(resultItem);
|
||||
AssertAreEqual(model[index], resultItem);
|
||||
}
|
||||
}
|
||||
|
||||
protected void CompoundModel_Regression_Battery<T>(T model)
|
||||
{
|
||||
var archetype = ConvertModelToArchetype(model);
|
||||
Assert.IsNotNull(archetype);
|
||||
|
||||
var archetypeJson = archetype.SerializeForPersistence();
|
||||
var modelJson = ConvertModelToArchetypeJson(model, Formatting.Indented);
|
||||
|
||||
Assert.IsNotNullOrEmpty(modelJson);
|
||||
|
||||
var result = ConvertModelToArchetypeAndBack(model);
|
||||
var resultfromArchetypeJson = ConvertArchetypeJsonToModel<T>(archetypeJson);
|
||||
|
||||
Assert.IsInstanceOf<T>(result);
|
||||
AssertAreEqual(model, result);
|
||||
|
||||
Assert.IsInstanceOf<T>(resultfromArchetypeJson);
|
||||
AssertAreEqual(model, resultfromArchetypeJson);
|
||||
}
|
||||
|
||||
protected void NestedModel_Regression_Battery<T>(T model)
|
||||
{
|
||||
CompoundModel_Regression_Battery(model);
|
||||
}
|
||||
|
||||
protected void ComplexModel_Regression_Battery<T>(T model)
|
||||
{
|
||||
CompoundModel_Regression_Battery(model);
|
||||
}
|
||||
|
||||
protected void AssertAreEqual<T>(T model, T result)
|
||||
{
|
||||
foreach (var propInfo in model.GetSerialiazableProperties())
|
||||
{
|
||||
var expected = GetExpectedValue(model, propInfo);
|
||||
var actual = GetActualValue(result, propInfo);
|
||||
|
||||
if (propInfo.PropertyType.Namespace.Equals("System"))
|
||||
{
|
||||
Assert.AreEqual(expected, actual);
|
||||
continue;
|
||||
}
|
||||
|
||||
var list = expected as IList;
|
||||
if (list != null)
|
||||
{
|
||||
foreach (var expectedItem in list)
|
||||
{
|
||||
var index = list.IndexOf(expectedItem);
|
||||
AssertAreEqual(expectedItem, ((IList)actual)[index]);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
AssertAreEqual(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
protected void EnsureUmbracoContext(Mock<IDataTypeService> dataTypeService)
|
||||
{
|
||||
var cacheHelper = CacheHelper.CreateDisabledCacheHelper();
|
||||
var serviceContext = new ServiceContext(
|
||||
Mock.Of<IContentService>(),
|
||||
Mock.Of<IMediaService>(),
|
||||
Mock.Of<IContentTypeService>(),
|
||||
dataTypeService.Object,
|
||||
Mock.Of<IFileService>(),
|
||||
Mock.Of<ILocalizationService>(),
|
||||
Mock.Of<IPackagingService>(),
|
||||
Mock.Of<IEntityService>(),
|
||||
Mock.Of<IRelationService>(),
|
||||
Mock.Of<IMemberGroupService>(),
|
||||
Mock.Of<IMemberTypeService>(),
|
||||
Mock.Of<IMemberService>(),
|
||||
Mock.Of<IUserService>(),
|
||||
Mock.Of<ISectionService>(),
|
||||
Mock.Of<IApplicationTreeService>(),
|
||||
Mock.Of<ITagService>(),
|
||||
Mock.Of<INotificationService>()
|
||||
);
|
||||
|
||||
ApplicationContext.EnsureContext(
|
||||
new DatabaseContext(Mock.Of<IDatabaseFactory>()), serviceContext, cacheHelper, true);
|
||||
}
|
||||
|
||||
private object GetExpectedValue<T>(T expected, PropertyInfo propInfo)
|
||||
{
|
||||
return propInfo.GetValue(expected, null);
|
||||
}
|
||||
|
||||
private object GetActualValue<T>(T actual, PropertyInfo propInfo)
|
||||
{
|
||||
var actualProp = actual.GetSerialiazableProperties().SingleOrDefault(pinfo => pinfo.Name.Equals(propInfo.Name));
|
||||
return actualProp != null
|
||||
? actualProp.GetValue(actual, null)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,253 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Archetype.PropertyEditors;
|
||||
using Archetype.Serialization;
|
||||
using Archetype.Tests.Serialization.Base;
|
||||
using Moq;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Editors;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Archetype.Tests.Serialization.Delinter
|
||||
{
|
||||
[TestFixture]
|
||||
public class ArchetypeJsonDelinterTest : RegressionTestBase
|
||||
{
|
||||
private const string _ESCAPED_JSON = @"{""fieldsets"":[{""properties"":[{""alias"":""slides"",""value"":""2680""}],""alias"":""slides""},{""properties"":[{""alias"":""captions"",""value"":""{\""fieldsets\"":[{\""properties\"":[{\""alias\"":\""textstring\"",\""value\"":\""test1 test1\""}],\""alias\"":\""textstringArray\""},{\""properties\"":[{\""alias\"":\""textstring\"",\""value\"":\""test2 test2\""}],\""alias\"":\""textstringArray\""},{\""properties\"":[{\""alias\"":\""textstring\"",\""value\"":\""test3b test3b\""}],\""alias\"":\""textstringArray\""}]}""}],""alias"":""captions""}]}";
|
||||
private const string _JSON = @"{""fieldsets"":[{""properties"":[{""alias"":""slides"",""value"":""2680""}],""alias"":""slides""},{""properties"":[{""alias"":""captions"",""value"":{""fieldsets"":[{""properties"":[{""alias"":""textstring"",""value"":""test1 test1""}],""alias"":""textstringArray""},{""properties"":[{""alias"":""textstring"",""value"":""test2 test2""}],""alias"":""textstringArray""},{""properties"":[{""alias"":""textstring"",""value"":""test3b test3b""}],""alias"":""textstringArray""}]}}],""alias"":""captions""}]}";
|
||||
private const string _ESCAPED_JSON_DEEP_NESTED = @"{""fieldsets"":[{""properties"":[{""alias"":""pages"",""value"":""""},{""alias"":""captions"",""value"":""{\""fieldsets\"":[{\""properties\"":[{\""alias\"":\""captions\"",\""value\"":\""{\\\""fieldsets\\\"":[{\\\""properties\\\"":[{\\\""alias\\\"":\\\""textString\\\"",\\\""value\\\"":\\\""{\\\\\\\""fieldsets\\\\\\\"":[{\\\\\\\""properties\\\\\\\"":[{\\\\\\\""alias\\\\\\\"":\\\\\\\""textString\\\\\\\"",\\\\\\\""value\\\\\\\"":\\\\\\\""\\\\\\\""}],\\\\\\\""alias\\\\\\\"":\\\\\\\""textItem\\\\\\\""}]}\\\""}],\\\""alias\\\"":\\\""textList\\\""}]}\""}],\""alias\"":\""captions\""}]}""}],""alias"":""pages""}]}";
|
||||
private const string _ESCAPED_JSON_FROM_APP = @"{
|
||||
""alias"": ""captions"",
|
||||
""value"": ""{\""fieldsets\"":[{\""properties\"":[{\""alias\"":\""textstring\"",\""value\"":\""test1 test1\""}],\""alias\"":\""textstringArray\""},{\""properties\"":[{\""alias\"":\""textstring\"",\""value\"":\""test2 test2\""}],\""alias\"":\""textstringArray\""},{\""properties\"":[{\""alias\"":\""textstring\"",\""value\"":\""test3b test3b\""}],\""alias\"":\""textstringArray\""}]}""
|
||||
}";
|
||||
|
||||
private SlideShow _referenceModel;
|
||||
private NestedClass _nestedClass;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_referenceModel = new SlideShow()
|
||||
{
|
||||
Slides = "2680",
|
||||
Captions = new Captions()
|
||||
{
|
||||
new TextString(){Text = "test1 test1"},
|
||||
new TextString(){Text = "test2 test2"},
|
||||
new TextString(){Text = "test3b test3b"}
|
||||
}
|
||||
};
|
||||
|
||||
_nestedClass = GetNestedClass();
|
||||
_nestedClass.SlideShow = _referenceModel;
|
||||
_nestedClass.Nested = GetNestedClass();
|
||||
_nestedClass.Nested.SlideShow = _referenceModel;
|
||||
_nestedClass.Nested.Nested = GetNestedClass();
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Delinter_RemoveNewLine_ByPasses_Values()
|
||||
{
|
||||
const string _JSON_WITH_RESERVED_CHARS = @"{
|
||||
""alias"": ""captions"",
|
||||
""value"": ""{ \""fieldsets\"": [
|
||||
{
|
||||
\""properties\"":
|
||||
[
|
||||
{ \""alias\"": \""textstring\"" , \""value\"":\""test1 \r\n test1\r\n\""}], \""alias\"":\""textstringArray\"" },{\""properties\"": [ { \""alias\"":\""textstring\"",\""value\"":\""test2\r\ntest2\""}],\""alias\"":\""textstringArray\""},{\""properties\"":[{\""alias\"":\""textstring\"",\""value\"":\""test3b \""quote\"" \\r\\r\\rtest3\""}],\""alias\"":\""textstringArray\"" } ] }""
|
||||
}";
|
||||
|
||||
var referenceModel = new Captions()
|
||||
{
|
||||
new TextString() {Text = @"test1
|
||||
test1
|
||||
"},
|
||||
new TextString() {Text = @"test2
|
||||
test2"},
|
||||
new TextString() {Text = @"test3b ""quote"" \r\r\rtest3"}
|
||||
};
|
||||
|
||||
var delintedJson = _JSON_WITH_RESERVED_CHARS.DelintArchetypeJson();
|
||||
var actualModel = ConvertArchetypeJsonToModel<Captions>(delintedJson);
|
||||
|
||||
var t = JToken.Parse(delintedJson).ToString(Formatting.None);
|
||||
|
||||
Assert.IsInstanceOf<Captions>(actualModel);
|
||||
Assert.IsNotNull(actualModel);
|
||||
|
||||
Assert.AreEqual(3, actualModel.Count);
|
||||
|
||||
foreach (var refItem in referenceModel)
|
||||
{
|
||||
var index = referenceModel.IndexOf(refItem);
|
||||
AssertAreEqual(refItem, actualModel.ElementAt(index));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReferenceJsonAndModel_Equal_ExpectedJsonAndModel()
|
||||
{
|
||||
const string expectedJson = _JSON;
|
||||
|
||||
var expectedModel = ConvertArchetypeJsonToModel<SlideShow>(expectedJson);
|
||||
var referenceModel = ConvertModelToArchetypeAndBack(_referenceModel);
|
||||
|
||||
Assert.IsInstanceOf<SlideShow>(expectedModel);
|
||||
Assert.IsInstanceOf<SlideShow>(referenceModel);
|
||||
|
||||
Assert.AreEqual(3, expectedModel.Captions.Count);
|
||||
Assert.AreEqual(3, referenceModel.Captions.Count);
|
||||
|
||||
AssertAreEqual(expectedModel, referenceModel);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnescapedJsonAndModel_Equal_ExpectedJsonAndModel()
|
||||
{
|
||||
const string expectedJson = _JSON;
|
||||
var unescapedJson = _ESCAPED_JSON.DelintArchetypeJson();
|
||||
|
||||
var expectedModel = ConvertArchetypeJsonToModel<SlideShow>(expectedJson);
|
||||
var actualModel = ConvertArchetypeJsonToModel<SlideShow>(unescapedJson);
|
||||
|
||||
Assert.IsInstanceOf<SlideShow>(expectedModel);
|
||||
Assert.IsInstanceOf<SlideShow>(actualModel);
|
||||
|
||||
Assert.AreEqual(3, expectedModel.Captions.Count);
|
||||
Assert.AreEqual(3, actualModel.Captions.Count);
|
||||
|
||||
AssertAreEqual(expectedModel, actualModel);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EscapedJson_FromApp_SerializesToModel()
|
||||
{
|
||||
var delintedJson = _ESCAPED_JSON_FROM_APP.DelintArchetypeJson();
|
||||
|
||||
var referenceModel = new Captions()
|
||||
{
|
||||
new TextString() {Text = "test1 test1"},
|
||||
new TextString() {Text = "test2 test2"},
|
||||
new TextString() {Text = "test3b test3b"}
|
||||
};
|
||||
|
||||
var actualModel = ConvertArchetypeJsonToModel<Captions>(delintedJson);
|
||||
|
||||
Assert.IsInstanceOf<Captions>(actualModel);
|
||||
Assert.AreEqual(3, actualModel.Count);
|
||||
|
||||
foreach (var refItem in referenceModel)
|
||||
{
|
||||
var index = referenceModel.IndexOf(refItem);
|
||||
AssertAreEqual(refItem, actualModel.ElementAt(index));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeepNestedJson_Escapes_Correctly()
|
||||
{
|
||||
var propGuid = new Guid();
|
||||
var dtd = new DataTypeDefinition(-1, String.Empty) { Id = 0 };
|
||||
|
||||
var dataTypeService = new Mock<IDataTypeService>();
|
||||
dataTypeService.Setup(dts => dts.GetDataTypeDefinitionById(Guid.Parse(propGuid.ToString()))).Returns(dtd);
|
||||
dataTypeService.Setup(dts => dts.GetPreValuesCollectionByDataTypeId(dtd.Id)).Returns(new PreValueCollection(new Dictionary<string, PreValue>()));
|
||||
|
||||
var propValueEditor = new Mock<ArchetypePropertyEditor.ArchetypePropertyValueEditor>(new PropertyValueEditor());
|
||||
propValueEditor.Setup(pe => pe.GetPropertyEditor(dtd)).Returns(new ArchetypePropertyEditor());
|
||||
|
||||
var archetype = ConvertModelToArchetype(_nestedClass);
|
||||
|
||||
foreach (var prop in archetype.Fieldsets.SelectMany(fs => fs.Properties))
|
||||
{
|
||||
prop.DataTypeGuid = propGuid.ToString();
|
||||
if (prop.Value.ToString().Contains("fieldsets"))
|
||||
prop.PropertyEditorAlias = Constants.PropertyEditorAlias;
|
||||
}
|
||||
|
||||
var archetypeJson = JsonConvert.SerializeObject(archetype);
|
||||
Assert.IsNotNullOrEmpty(archetypeJson);
|
||||
|
||||
EnsureUmbracoContext(dataTypeService);
|
||||
|
||||
var propEditor = new ArchetypePropertyEditor.ArchetypePropertyValueEditor(new PropertyValueEditor());
|
||||
var convertedJson = propEditor.ConvertEditorToDb(new ContentPropertyData(JObject.FromObject(archetype),
|
||||
new PreValueCollection(new Dictionary<string, PreValue>()), new Dictionary<string, object>()),
|
||||
archetypeJson);
|
||||
|
||||
Assert.IsNotNull(convertedJson);
|
||||
|
||||
var delintedJson = convertedJson.ToString().DelintArchetypeJson();
|
||||
Assert.IsNotNullOrEmpty(delintedJson);
|
||||
|
||||
var modelfromArchetypeJson = ConvertArchetypeJsonToModel<NestedClass>(archetypeJson);
|
||||
var modelfromConvertedJson = ConvertArchetypeJsonToModel<NestedClass>(delintedJson);
|
||||
|
||||
Assert.IsInstanceOf<NestedClass>(modelfromArchetypeJson);
|
||||
Assert.IsInstanceOf<NestedClass>(modelfromConvertedJson);
|
||||
|
||||
Assert.AreEqual(3, modelfromArchetypeJson.SlideShow.Captions.Count);
|
||||
Assert.AreEqual(3, modelfromConvertedJson.SlideShow.Captions.Count);
|
||||
|
||||
Assert.AreEqual(3, modelfromArchetypeJson.Nested.SlideShow.Captions.Count);
|
||||
Assert.AreEqual(3, modelfromConvertedJson.Nested.SlideShow.Captions.Count);
|
||||
|
||||
AssertAreEqual(modelfromArchetypeJson, modelfromConvertedJson);
|
||||
|
||||
}
|
||||
|
||||
#region private methods
|
||||
|
||||
private NestedClass GetNestedClass()
|
||||
{
|
||||
return new NestedClass();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region classes
|
||||
|
||||
[AsArchetype("slides")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class SlideShow
|
||||
{
|
||||
[JsonProperty("slides")]
|
||||
public string Slides { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("captions")]
|
||||
public Captions Captions { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("textstringArray")] /* Note: when inheriting from a list, archetype alias is not used */
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class Captions : List<TextString>
|
||||
{
|
||||
}
|
||||
|
||||
[AsArchetype("textstringArray")] /* due to hard coded string calues above, must have same archetype alias as list class */
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class TextString
|
||||
{
|
||||
[JsonProperty("textstring")]
|
||||
public String Text { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("nestedClass")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class NestedClass
|
||||
{
|
||||
[JsonProperty("nestedClass")]
|
||||
public NestedClass Nested { get; set; }
|
||||
[JsonProperty("slides")]
|
||||
public SlideShow SlideShow { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Archetype.Tests.Serialization.Regression
|
||||
{
|
||||
[TestFixture]
|
||||
public class ArchetypeJsonConverterLegacySetUpTest
|
||||
{
|
||||
[Test]
|
||||
public void Deserialize_SlideShow_FromArchetype()
|
||||
{
|
||||
var result = JsonConvert.DeserializeObject<SlideShow>(JsonTestStrings._SLIDES_JSON);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.IsInstanceOf<SlideShow>(result);
|
||||
|
||||
Assert.AreEqual("1,2,3,4,5", result.Slides);
|
||||
Assert.AreEqual("Test 1", result.Captions.TextStringArray.ElementAt(0).Text);
|
||||
Assert.AreEqual("Test 2", result.Captions.TextStringArray.ElementAt(1).Text);
|
||||
Assert.AreEqual("Test 3", result.Captions.TextStringArray.ElementAt(2).Text);
|
||||
Assert.AreEqual("Test 4", result.Captions.TextStringArray.ElementAt(3).Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
using Archetype.Tests.Serialization.Base;
|
||||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Archetype.Tests.Serialization.Regression
|
||||
{
|
||||
[TestFixture]
|
||||
public class ArchetypeJsonConverterTest : RegressionTestBase
|
||||
{
|
||||
private SerializationTestHelper _testHelper;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_testHelper = new SerializationTestHelper();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EmptyArray_Returns_Null()
|
||||
{
|
||||
var archetypeJson = @"{""fieldsets"": []}";
|
||||
var result = ConvertArchetypeJsonToModel<SimpleModel>(archetypeJson);
|
||||
|
||||
Assert.IsNull(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SimpleModel_Regression_Battery()
|
||||
{
|
||||
var simpleModel = _testHelper.GetModel<SimpleModel>();
|
||||
SimpleModel_Regression_Battery(simpleModel);
|
||||
|
||||
var json = ConvertModelToArchetypeJson(simpleModel, Formatting.Indented);
|
||||
Assert.AreEqual(JsonTestStrings._SIMPLE_JSON, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SimpleModelWithFieldsets_Regression_Battery()
|
||||
{
|
||||
var simpleModel = _testHelper.GetModel<SimpleModelWithFieldsets>();
|
||||
SimpleModel_Regression_Battery(simpleModel);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SimpleModelWithMixedFieldsets_Regression_Battery()
|
||||
{
|
||||
var simpleModel = _testHelper.GetModel<SimpleModelWithMixedFieldsets>();
|
||||
SimpleModel_Regression_Battery(simpleModel);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SimpleModels_Regression_Battery()
|
||||
{
|
||||
var simpleModels = _testHelper.GetModel<SimpleModels>();
|
||||
SimpleModels_Regression_Battery(simpleModels);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SimpleModelsWithFieldsets_Regression_Battery()
|
||||
{
|
||||
var simpleModels = _testHelper.GetModel<SimpleModelsWithFieldsets>();
|
||||
SimpleModels_Regression_Battery(simpleModels);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SimpleModelsWithMixedFieldsets_Regression_Battery()
|
||||
{
|
||||
var simpleModels = _testHelper.GetModel<SimpleModelsWithMixedFieldsets>();
|
||||
SimpleModels_Regression_Battery(simpleModels);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CompoundModel_Regression_Battery()
|
||||
{
|
||||
var compoundModel = _testHelper.GetModel<CompoundModel>();
|
||||
CompoundModel_Regression_Battery(compoundModel);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CompoundModelWithMixedFieldsetVariant1_Regression_Battery()
|
||||
{
|
||||
var compoundModel = _testHelper.GetModel<CompoundModelWithMixedFieldsetVariant1>();
|
||||
CompoundModel_Regression_Battery(compoundModel);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CompoundModelWithMixedFieldsetVariant2_Regression_Battery()
|
||||
{
|
||||
var compoundModel = _testHelper.GetModel<CompoundModelWithMixedFieldsetVariant2>();
|
||||
CompoundModel_Regression_Battery(compoundModel);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CompoundModelWithFieldset_Regression_Battery()
|
||||
{
|
||||
var compoundModel = _testHelper.GetModel<CompoundModelWithFieldset>();
|
||||
CompoundModel_Regression_Battery(compoundModel);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CompoundModelWithList_Regression_Battery()
|
||||
{
|
||||
var compoundModelWithList = _testHelper.GetModel<CompoundModelWithList>();
|
||||
CompoundModel_Regression_Battery(compoundModelWithList);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CompoundModelWithMixedFieldsetWithList_Regression_Battery()
|
||||
{
|
||||
var compoundModelWithList = _testHelper.GetModel<CompoundModelWithMixedFieldsetWithList>();
|
||||
CompoundModel_Regression_Battery(compoundModelWithList);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CompoundModelWithFieldsetWithList_Regression_Battery()
|
||||
{
|
||||
var compoundModelWithList = _testHelper.GetModel<CompoundModelWithFieldsetWithList>();
|
||||
CompoundModel_Regression_Battery(compoundModelWithList);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NestedModel_Regression_Battery()
|
||||
{
|
||||
var nestedModel = _testHelper.GetModel<NestedModel>();
|
||||
NestedModel_Regression_Battery(nestedModel);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NestedModelWithMixedFieldset_Regression_Battery()
|
||||
{
|
||||
var nestedModel = _testHelper.GetModel<NestedModelWithMixedFieldset>();
|
||||
NestedModel_Regression_Battery(nestedModel);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NestedModelWithFieldset_Regression_Battery()
|
||||
{
|
||||
var nestedModel = _testHelper.GetModel<NestedModelWithFieldset>();
|
||||
NestedModel_Regression_Battery(nestedModel);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ComplexModel_Regression_Battery()
|
||||
{
|
||||
var complexModel = _testHelper.GetModel<ComplexModel>();
|
||||
NestedModel_Regression_Battery(complexModel);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Archetype.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Archetype.Tests.Serialization.Regression
|
||||
{
|
||||
[AsArchetype("textstringArray")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class TextString
|
||||
{
|
||||
[JsonProperty("textstring")]
|
||||
public String Text { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("textstringArray")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class TextStringArray : List<TextString>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[AsArchetype("captions")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class Captions
|
||||
{
|
||||
[JsonProperty("captions")]
|
||||
public TextStringArray TextStringArray { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("slides")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class SlideShow
|
||||
{
|
||||
[JsonProperty("slides")]
|
||||
public string Slides { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("captions")]
|
||||
public Captions Captions { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,257 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Archetype.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Archetype.Tests.Serialization.Regression
|
||||
{
|
||||
[AsArchetype("simpleModel")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class SimpleModel
|
||||
{
|
||||
[JsonProperty("text")]
|
||||
public String Text { get; set; }
|
||||
[JsonProperty("integer")]
|
||||
public int Id { get; set; }
|
||||
[JsonProperty("nullableInteger")]
|
||||
public int? NullableId { get; set; }
|
||||
[JsonProperty("double")]
|
||||
public double Amount { get; set; }
|
||||
[JsonProperty("nullableDouble")]
|
||||
public double? NullableAmount { get; set; }
|
||||
[JsonProperty("dateTime")]
|
||||
public DateTime DateOne { get; set; }
|
||||
[JsonProperty("nullableDateTime")]
|
||||
public DateTime? DateTwo { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("simpleModel")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class SimpleModelWithFieldsets
|
||||
{
|
||||
[AsFieldset]
|
||||
[JsonProperty("text")]
|
||||
public string Text { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("integer")]
|
||||
public int Id { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("nullableInteger")]
|
||||
public int? NullableId { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("double")]
|
||||
public double Amount { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("nullableDouble")]
|
||||
public double? NullableAmount { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("dateTime")]
|
||||
public DateTime DateOne { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("nullableDateTime")]
|
||||
public DateTime? DateTwo { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("simpleModel")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class SimpleModelWithMixedFieldsets
|
||||
{
|
||||
[AsFieldset]
|
||||
[JsonProperty("text")]
|
||||
public string Text { get; set; }
|
||||
[JsonProperty("integer")]
|
||||
public int Id { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("nullableInteger")]
|
||||
public int? NullableId { get; set; }
|
||||
[JsonProperty("double")]
|
||||
public double Amount { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("nullableDouble")]
|
||||
public double? NullableAmount { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("dateTime")]
|
||||
public DateTime DateOne { get; set; }
|
||||
public DateTime? DateTwo { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("simpleModels")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class SimpleModels : List<SimpleModel>
|
||||
{
|
||||
}
|
||||
|
||||
[AsArchetype("simpleModels")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class SimpleModelsWithFieldsets : List<SimpleModelWithFieldsets>
|
||||
{
|
||||
}
|
||||
|
||||
[AsArchetype("simpleModels")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class SimpleModelsWithMixedFieldsets : List<SimpleModelWithMixedFieldsets>
|
||||
{
|
||||
}
|
||||
|
||||
[AsArchetype("compoundModel")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class CompoundModel
|
||||
{
|
||||
[JsonProperty("simpleModel")]
|
||||
public SimpleModel SimpleModel { get; set; }
|
||||
[JsonProperty("text")]
|
||||
public String Text { get; set; }
|
||||
[JsonProperty("integer")]
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("compoundModelWithMixedFieldset")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class CompoundModelWithMixedFieldsetVariant1
|
||||
{
|
||||
[AsFieldset]
|
||||
[JsonProperty("simpleModel")]
|
||||
public SimpleModel SimpleModel { get; set; }
|
||||
[JsonProperty("text")]
|
||||
public String Text { get; set; }
|
||||
[JsonProperty("integer")]
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("compoundModelWithMixedFieldset")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class CompoundModelWithMixedFieldsetVariant2
|
||||
{
|
||||
[JsonProperty("simpleModel")]
|
||||
public SimpleModel SimpleModel { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("text")]
|
||||
public String Text { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("integer")]
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("compoundModel")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class CompoundModelWithFieldset
|
||||
{
|
||||
[AsFieldset]
|
||||
[JsonProperty("simpleModel")]
|
||||
public SimpleModel SimpleModel { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("text")]
|
||||
public String Text { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("integer")]
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("compoundModelWithList")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class CompoundModelWithList
|
||||
{
|
||||
[JsonProperty("simpleModelList")]
|
||||
public List<SimpleModel> SimpleModelList { get; set; }
|
||||
[JsonProperty("text")]
|
||||
public String Text { get; set; }
|
||||
[JsonProperty("integer")]
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("compoundModelWithList")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class CompoundModelWithMixedFieldsetWithList
|
||||
{
|
||||
[JsonProperty("simpleModelList")]
|
||||
public List<SimpleModel> SimpleModelList { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("text")]
|
||||
public String Text { get; set; }
|
||||
[JsonProperty("integer")]
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("compoundModelWithList")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class CompoundModelWithFieldsetWithList
|
||||
{
|
||||
[AsFieldset]
|
||||
[JsonProperty("simpleModelList")]
|
||||
public List<SimpleModel> SimpleModelList { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("text")]
|
||||
public String Text { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("integer")]
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("nestedModel")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class NestedModel
|
||||
{
|
||||
[JsonProperty("compoundModel")]
|
||||
public CompoundModel CompoundModel { get; set; }
|
||||
[JsonProperty("simpleModel")]
|
||||
public SimpleModel SimpleModel { get; set; }
|
||||
[JsonProperty("text")]
|
||||
public String Text { get; set; }
|
||||
[JsonProperty("integer")]
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("nestedModel")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class NestedModelWithMixedFieldset
|
||||
{
|
||||
[JsonProperty("compoundModel")]
|
||||
public CompoundModel CompoundModel { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("simpleModel")]
|
||||
public SimpleModel SimpleModel { get; set; }
|
||||
[JsonProperty("text")]
|
||||
public String Text { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("integer")]
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("nestedModel")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class NestedModelWithFieldset
|
||||
{
|
||||
[AsFieldset]
|
||||
[JsonProperty("compoundModel")]
|
||||
public CompoundModel CompoundModel { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("simpleModel")]
|
||||
public SimpleModel SimpleModel { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("text")]
|
||||
public String Text { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("integer")]
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("complexModel")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class ComplexModel
|
||||
{
|
||||
[JsonProperty("compoundModels")]
|
||||
public CompoundModelWrapper CompoundModelWrapper { get; set; }
|
||||
[JsonProperty("text")]
|
||||
public String Text { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("compoundModelWrapper")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class CompoundModelWrapper
|
||||
{
|
||||
[JsonProperty("compoundModels")]
|
||||
public List<CompoundModel> CompoundModels { get; set; }
|
||||
[JsonProperty("text")]
|
||||
public String Text { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
namespace Archetype.Tests.Serialization.Regression
|
||||
{
|
||||
public class JsonTestStrings
|
||||
{
|
||||
public const string _SIMPLE_JSON = @"{
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""simpleModel"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""text"",
|
||||
""value"": ""Test \r\nText \""quote\"" \r\n""
|
||||
},
|
||||
{
|
||||
""alias"": ""integer"",
|
||||
""value"": ""123""
|
||||
},
|
||||
{
|
||||
""alias"": ""nullableInteger"",
|
||||
""value"": """"
|
||||
},
|
||||
{
|
||||
""alias"": ""double"",
|
||||
""value"": ""5.67""
|
||||
},
|
||||
{
|
||||
""alias"": ""nullableDouble"",
|
||||
""value"": """"
|
||||
},
|
||||
{
|
||||
""alias"": ""dateTime"",
|
||||
""value"": ""01/01/2000 00:00:00""
|
||||
},
|
||||
{
|
||||
""alias"": ""nullableDateTime"",
|
||||
""value"": """"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}";
|
||||
public const string _ESCAPED_JSON =
|
||||
@"{
|
||||
""fieldsets"":[
|
||||
{
|
||||
""properties"":[
|
||||
{
|
||||
""alias"":""pages"",
|
||||
""value"":""2439,2440,2441,2442,2443,2444,2445,2446,2447,2448,2449,2450,2451,2452,2453""
|
||||
},
|
||||
{
|
||||
""alias"":""captions"",
|
||||
""value"":""{\""fieldsets\"":[{\""properties\"":[{\""alias\"":\""captions\"",\""value\"":\""{\\\""fieldsets\\\"":[{\\\""properties\\\"":[{\\\""alias\\\"":\\\""textString\\\"",\\\""value\\\"":\\\""{\\\\\\\""fieldsets\\\\\\\"":[{\\\\\\\""properties\\\\\\\"":[{\\\\\\\""alias\\\\\\\"":\\\\\\\""textString\\\\\\\"",\\\\\\\""value\\\\\\\"":\\\\\\\""First Page\\\\\\\"",\\\\\\\""propertyEditorAlias\\\\\\\"":\\\\\\\""Umbraco.Textbox\\\\\\\"",\\\\\\\""dataTypeId\\\\\\\"":-88,\\\\\\\""dataTypeGuid\\\\\\\"":\\\\\\\""0cc0eba1-9960-42c9-bf9b-60e150b429ae\\\\\\\""}],\\\\\\\""alias\\\\\\\"":\\\\\\\""textItem\\\\\\\""}]}\\\"",\\\""propertyEditorAlias\\\"":\\\""Imulus.Archetype\\\"",\\\""dataTypeId\\\"":3764,\\\""dataTypeGuid\\\"":\\\""496cfe35-448f-4b59-9c75-050798afdce4\\\""}],\\\""alias\\\"":\\\""textList\\\""},{\\\""properties\\\"":[{\\\""alias\\\"":\\\""textString\\\"",\\\""value\\\"":\\\""{\\\\\\\""fieldsets\\\\\\\"":[{\\\\\\\""properties\\\\\\\"":[{\\\\\\\""alias\\\\\\\"":\\\\\\\""textString\\\\\\\"",\\\\\\\""value\\\\\\\"":\\\\\\\""Second Page\\\\\\\"",\\\\\\\""propertyEditorAlias\\\\\\\"":\\\\\\\""Umbraco.Textbox\\\\\\\"",\\\\\\\""dataTypeId\\\\\\\"":-88,\\\\\\\""dataTypeGuid\\\\\\\"":\\\\\\\""0cc0eba1-9960-42c9-bf9b-60e150b429ae\\\\\\\""}],\\\\\\\""alias\\\\\\\"":\\\\\\\""textItem\\\\\\\""}]}\\\"",\\\""propertyEditorAlias\\\"":\\\""Imulus.Archetype\\\"",\\\""dataTypeId\\\"":3764,\\\""dataTypeGuid\\\"":\\\""496cfe35-448f-4b59-9c75-050798afdce4\\\""}],\\\""alias\\\"":\\\""textList\\\""},{\\\""properties\\\"":[{\\\""alias\\\"":\\\""textString\\\"",\\\""value\\\"":\\\""{\\\\\\\""fieldsets\\\\\\\"":[{\\\\\\\""properties\\\\\\\"":[{\\\\\\\""alias\\\\\\\"":\\\\\\\""textString\\\\\\\"",\\\\\\\""value\\\\\\\"":\\\\\\\""Third Page\\\\\\\"",\\\\\\\""propertyEditorAlias\\\\\\\"":\\\\\\\""Umbraco.Textbox\\\\\\\"",\\\\\\\""dataTypeId\\\\\\\"":-88,\\\\\\\""dataTypeGuid\\\\\\\"":\\\\\\\""0cc0eba1-9960-42c9-bf9b-60e150b429ae\\\\\\\""}],\\\\\\\""alias\\\\\\\"":\\\\\\\""textItem\\\\\\\""}]}\\\"",\\\""propertyEditorAlias\\\"":\\\""Imulus.Archetype\\\"",\\\""dataTypeId\\\"":3764,\\\""dataTypeGuid\\\"":\\\""496cfe35-448f-4b59-9c75-050798afdce4\\\""}],\\\""alias\\\"":\\\""textList\\\""},{\\\""properties\\\"":[{\\\""alias\\\"":\\\""textString\\\"",\\\""value\\\"":\\\""{\\\\\\\""fieldsets\\\\\\\"":[{\\\\\\\""properties\\\\\\\"":[{\\\\\\\""alias\\\\\\\"":\\\\\\\""textString\\\\\\\"",\\\\\\\""value\\\\\\\"":\\\\\\\""Fourth Page\\\\\\\"",\\\\\\\""propertyEditorAlias\\\\\\\"":\\\\\\\""Umbraco.Textbox\\\\\\\"",\\\\\\\""dataTypeId\\\\\\\"":-88,\\\\\\\""dataTypeGuid\\\\\\\"":\\\\\\\""0cc0eba1-9960-42c9-bf9b-60e150b429ae\\\\\\\""}],\\\\\\\""alias\\\\\\\"":\\\\\\\""textItem\\\\\\\""}]}\\\"",\\\""propertyEditorAlias\\\"":\\\""Imulus.Archetype\\\"",\\\""dataTypeId\\\"":3764,\\\""dataTypeGuid\\\"":\\\""496cfe35-448f-4b59-9c75-050798afdce4\\\""}],\\\""alias\\\"":\\\""textList\\\""}]}\"",\""propertyEditorAlias\"":\""Imulus.Archetype\"",\""dataTypeId\"":3765,\""dataTypeGuid\"":\""4ed439b3-0ee7-447a-a64e-b2b486b86379\""}],\""alias\"":\""captions\""}]}""
|
||||
}
|
||||
],
|
||||
""alias"":""pages""
|
||||
}
|
||||
]
|
||||
}";
|
||||
|
||||
public const string _SLIDES_JSON =
|
||||
@"{
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""captions"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""captions"",
|
||||
""value"": {
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""textstringArray"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""textstring"",
|
||||
""value"": ""Test 1""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""alias"": ""textstringArray"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""textstring"",
|
||||
""value"": ""Test 2""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""alias"": ""textstringArray"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""textstring"",
|
||||
""value"": ""Test 3""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""alias"": ""textstringArray"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""textstring"",
|
||||
""value"": ""Test 4""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""alias"": ""slides"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""slides"",
|
||||
""value"": ""1,2,3,4,5""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}";
|
||||
}
|
||||
}
|
||||
@@ -1,220 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Archetype.Tests.Serialization.Regression
|
||||
{
|
||||
public class SerializationTestHelper
|
||||
{
|
||||
public T GetModel<T>()
|
||||
{
|
||||
try
|
||||
{
|
||||
return (T)GetType().GetMethod("Get" + typeof(T).Name).Invoke(this, null);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
|
||||
public SimpleModel GetSimpleModel()
|
||||
{
|
||||
return new SimpleModel
|
||||
{
|
||||
Amount = 5.67,
|
||||
NullableAmount = null,
|
||||
DateOne = new DateTime(2000, 1, 1),
|
||||
DateTwo = null,
|
||||
Id = 123,
|
||||
NullableId = null,
|
||||
Text = @"Test
|
||||
Text ""quote""
|
||||
"
|
||||
};
|
||||
}
|
||||
|
||||
public SimpleModelWithFieldsets GetSimpleModelWithFieldsets()
|
||||
{
|
||||
return new SimpleModelWithFieldsets
|
||||
{
|
||||
Amount = 5.67,
|
||||
NullableAmount = null,
|
||||
DateOne = new DateTime(2000, 1, 1),
|
||||
DateTwo = null,
|
||||
Id = 123,
|
||||
NullableId = null,
|
||||
Text = "Test Text"
|
||||
};
|
||||
}
|
||||
|
||||
public SimpleModelWithMixedFieldsets GetSimpleModelWithMixedFieldsets()
|
||||
{
|
||||
return new SimpleModelWithMixedFieldsets
|
||||
{
|
||||
Amount = 5.67,
|
||||
NullableAmount = null,
|
||||
DateOne = new DateTime(2000, 1, 1),
|
||||
DateTwo = null,
|
||||
Id = 123,
|
||||
NullableId = null,
|
||||
Text = "Test Text"
|
||||
};
|
||||
}
|
||||
|
||||
public SimpleModels GetSimpleModels()
|
||||
{
|
||||
return new SimpleModels
|
||||
{
|
||||
GetSimpleModel(),
|
||||
GetSimpleModel(),
|
||||
GetSimpleModel()
|
||||
};
|
||||
}
|
||||
|
||||
public SimpleModelsWithFieldsets GetSimpleModelsWithFieldsets()
|
||||
{
|
||||
return new SimpleModelsWithFieldsets
|
||||
{
|
||||
GetSimpleModelWithFieldsets(),
|
||||
GetSimpleModelWithFieldsets(),
|
||||
GetSimpleModelWithFieldsets()
|
||||
};
|
||||
}
|
||||
|
||||
public SimpleModelsWithMixedFieldsets GetSimpleModelsWithMixedFieldsets()
|
||||
{
|
||||
return new SimpleModelsWithMixedFieldsets
|
||||
{
|
||||
GetSimpleModelWithMixedFieldsets(),
|
||||
GetSimpleModelWithMixedFieldsets(),
|
||||
GetSimpleModelWithMixedFieldsets()
|
||||
};
|
||||
}
|
||||
|
||||
public CompoundModel GetCompoundModel()
|
||||
{
|
||||
return new CompoundModel
|
||||
{
|
||||
Id = -1,
|
||||
SimpleModel = GetModel<SimpleModel>(),
|
||||
Text = typeof(CompoundModel).Name
|
||||
};
|
||||
}
|
||||
|
||||
public CompoundModelWithMixedFieldsetVariant1 GetCompoundModelWithMixedFieldsetVariant1()
|
||||
{
|
||||
return new CompoundModelWithMixedFieldsetVariant1
|
||||
{
|
||||
Id = -1,
|
||||
SimpleModel = GetModel<SimpleModel>(),
|
||||
Text = typeof(CompoundModelWithMixedFieldsetVariant1).Name
|
||||
};
|
||||
}
|
||||
|
||||
public CompoundModelWithMixedFieldsetVariant2 GetCompoundModelWithMixedFieldsetVariant2()
|
||||
{
|
||||
return new CompoundModelWithMixedFieldsetVariant2
|
||||
{
|
||||
Id = -1,
|
||||
SimpleModel = GetModel<SimpleModel>(),
|
||||
Text = typeof(CompoundModelWithMixedFieldsetVariant2).Name
|
||||
};
|
||||
}
|
||||
|
||||
public CompoundModelWithFieldset GetCompoundModelWithFieldset()
|
||||
{
|
||||
return new CompoundModelWithFieldset
|
||||
{
|
||||
Id = -1,
|
||||
SimpleModel = GetModel<SimpleModel>(),
|
||||
Text = typeof(CompoundModelWithFieldset).Name
|
||||
};
|
||||
}
|
||||
|
||||
public CompoundModelWithList GetCompoundModelWithList()
|
||||
{
|
||||
return new CompoundModelWithList
|
||||
{
|
||||
Id = 10,
|
||||
SimpleModelList = GetModel<SimpleModels>(),
|
||||
Text = typeof(CompoundModelWithList).Name
|
||||
};
|
||||
}
|
||||
|
||||
public CompoundModelWithMixedFieldsetWithList GetCompoundModelWithMixedFieldsetWithList()
|
||||
{
|
||||
return new CompoundModelWithMixedFieldsetWithList
|
||||
{
|
||||
Id = 11,
|
||||
SimpleModelList = GetModel<SimpleModels>(),
|
||||
Text = typeof(CompoundModelWithMixedFieldsetWithList).Name
|
||||
};
|
||||
}
|
||||
|
||||
public CompoundModelWithFieldsetWithList GetCompoundModelWithFieldsetWithList()
|
||||
{
|
||||
return new CompoundModelWithFieldsetWithList
|
||||
{
|
||||
Id = 12,
|
||||
SimpleModelList = GetModel<SimpleModels>(),
|
||||
Text = typeof(CompoundModelWithFieldsetWithList).Name
|
||||
};
|
||||
}
|
||||
|
||||
public NestedModel GetNestedModel()
|
||||
{
|
||||
return new NestedModel
|
||||
{
|
||||
CompoundModel = GetModel<CompoundModel>(),
|
||||
Id = 53,
|
||||
SimpleModel = GetModel<SimpleModel>(),
|
||||
Text = typeof(NestedModel).Name
|
||||
};
|
||||
}
|
||||
|
||||
public NestedModelWithMixedFieldset GetNestedModelWithMixedFieldset()
|
||||
{
|
||||
return new NestedModelWithMixedFieldset
|
||||
{
|
||||
CompoundModel = GetModel<CompoundModel>(),
|
||||
Id = 54,
|
||||
SimpleModel = GetModel<SimpleModel>(),
|
||||
Text = typeof(NestedModelWithMixedFieldset).Name
|
||||
};
|
||||
}
|
||||
|
||||
public NestedModelWithFieldset GetNestedModelWithFieldset()
|
||||
{
|
||||
return new NestedModelWithFieldset
|
||||
{
|
||||
CompoundModel = GetModel<CompoundModel>(),
|
||||
Id = 55,
|
||||
SimpleModel = GetModel<SimpleModel>(),
|
||||
Text = typeof(NestedModelWithFieldset).Name
|
||||
};
|
||||
}
|
||||
|
||||
public CompoundModelWrapper GetCompoundModelWrapper()
|
||||
{
|
||||
return new CompoundModelWrapper
|
||||
{
|
||||
CompoundModels = new List<CompoundModel>
|
||||
{
|
||||
GetModel<CompoundModel>(),
|
||||
GetModel<CompoundModel>(),
|
||||
GetModel<CompoundModel>()
|
||||
},
|
||||
Text = typeof(CompoundModelWrapper).Name
|
||||
};
|
||||
}
|
||||
|
||||
public ComplexModel GetComplexModel()
|
||||
{
|
||||
return new ComplexModel
|
||||
{
|
||||
CompoundModelWrapper = GetModel<CompoundModelWrapper>(),
|
||||
Text = typeof(ComplexModel).Name
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,343 +0,0 @@
|
||||
using System;
|
||||
using Archetype.Tests.Serialization.Base;
|
||||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Archetype.Tests.Serialization.UseCases
|
||||
{
|
||||
[TestFixture]
|
||||
public class ArchetypeJsonConverterTest : ArchetypeJsonConverterTestBase
|
||||
{
|
||||
private ContactDetails _contactDetails;
|
||||
private CompanyDetails _companyDetails;
|
||||
private AnnualStatement _annualStatement;
|
||||
private MergerDetails _mergerDetails;
|
||||
private UrlPicker _webSite;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_webSite = new UrlPicker
|
||||
{
|
||||
Url = "http://test.com",
|
||||
Title = "The Test Company",
|
||||
OpenInNewWindow = true
|
||||
};
|
||||
|
||||
_mergerDetails = new MergerDetails
|
||||
{
|
||||
MergerDate = new DateTime(2014,6,7,8,9,10),
|
||||
MergerValue = 12345676890.12m
|
||||
};
|
||||
|
||||
_contactDetails = new ContactDetails
|
||||
{
|
||||
Address = "Test Address",
|
||||
Email = "test@test.com",
|
||||
Fax = "000",
|
||||
Mobile = "000",
|
||||
Name = "Test",
|
||||
Telephone = "111",
|
||||
WebSite = _webSite
|
||||
};
|
||||
|
||||
_companyDetails = new CompanyDetails
|
||||
{
|
||||
Region = "Test Region",
|
||||
ContactDetails = _contactDetails
|
||||
};
|
||||
|
||||
_annualStatement = new AnnualStatement
|
||||
{
|
||||
FiscalYearStart = new DateTime(2013, 9, 1),
|
||||
FiscalYearEnd = new DateTime(2014, 8, 31),
|
||||
TotalShares = 345678,
|
||||
Sales = 123456700.89,
|
||||
Profit = 1123456.78m
|
||||
};
|
||||
}
|
||||
|
||||
#region serialization tests
|
||||
|
||||
[Test]
|
||||
public void Convert_MergerDetailsModel_To_ArchetypeJson()
|
||||
{
|
||||
var result = ConvertModelToArchetypeJson(_mergerDetails, Formatting.Indented);
|
||||
Assert.AreEqual(JsonTestStrings._MERGER_DETAILS_JSON, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_ContactDetailsModel_To_ArchetypeJson()
|
||||
{
|
||||
var result = ConvertModelToArchetypeJson(_contactDetails, Formatting.Indented);
|
||||
Assert.AreEqual(JsonTestStrings._CONTACT_DETAILS_JSON, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_CompanyDetailsModel_To_ArchetypeJson()
|
||||
{
|
||||
var result = ConvertModelToArchetypeJson(_companyDetails, Formatting.Indented);
|
||||
|
||||
Assert.AreEqual(JsonTestStrings._COMPANY_DETAILS_JSON, result);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_AnnualStatementModel_To_ArchetypeJson()
|
||||
{
|
||||
var result = ConvertModelToArchetypeJson(_annualStatement, Formatting.Indented);
|
||||
|
||||
Assert.AreEqual(JsonTestStrings._ANNUAL_STATEMENT_JSON, result);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NullValues_Serialize_To_Empty_String()
|
||||
{
|
||||
var result = ConvertModelToArchetypeJson(new ContactDetails());
|
||||
|
||||
Assert.AreEqual(JsonTestStrings._NULL_VALUES_JSON, result);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_ContactDetailsModel_To_Archetype()
|
||||
{
|
||||
var model = new ContactDetails
|
||||
{
|
||||
Address = "addr",
|
||||
Email = "email"
|
||||
};
|
||||
|
||||
Assert.NotNull(ConvertModelToArchetype(model));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_AnnualStatementModel_To_Archetype()
|
||||
{
|
||||
Assert.NotNull(ConvertModelToArchetype(_annualStatement));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_AllContactDetailsModel_To_Archetype()
|
||||
{
|
||||
var item1 = new ContactDetails
|
||||
{
|
||||
Address = "addr",
|
||||
Email = "email"
|
||||
};
|
||||
|
||||
var item2 = new ContactDetails
|
||||
{
|
||||
Address = "addr1",
|
||||
Name = "email2"
|
||||
};
|
||||
|
||||
var model = new AllContactDetails
|
||||
{
|
||||
UserDetails = item1,
|
||||
AdminDetails = item2
|
||||
};
|
||||
|
||||
Assert.NotNull(ConvertModelToArchetype(model));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_ContactDetailsListModel_To_Archetype()
|
||||
{
|
||||
var item1 = new ContactDetails
|
||||
{
|
||||
Address = "addr",
|
||||
Email = "email"
|
||||
};
|
||||
|
||||
var item2 = new ContactDetails
|
||||
{
|
||||
Address = "addr1",
|
||||
Name = "email2"
|
||||
};
|
||||
|
||||
var model = new ContactDetailsList
|
||||
{
|
||||
item1,
|
||||
item2
|
||||
};
|
||||
|
||||
Assert.NotNull(ConvertModelToArchetype(model));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_CompanyDetailsModel_To_Archetype()
|
||||
{
|
||||
var model = new CompanyDetails
|
||||
{
|
||||
Region = "Test Region",
|
||||
ContactDetails = new ContactDetails
|
||||
{
|
||||
Address = "addr1",
|
||||
Name = "email2"
|
||||
}
|
||||
};
|
||||
|
||||
Assert.NotNull(ConvertModelToArchetype(model));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region deserialization tests
|
||||
|
||||
[Test]
|
||||
public void Convert_ArchetypeJson_To_ContactDetailsModel()
|
||||
{
|
||||
var result = ConvertArchetypeJsonToModel<ContactDetails>(JsonTestStrings._CONTACT_DETAILS_JSON);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.IsInstanceOf<ContactDetails>(result);
|
||||
|
||||
Assert.AreEqual("Test Address", result.Address);
|
||||
Assert.AreEqual("test@test.com", result.Email);
|
||||
Assert.AreEqual("000", result.Fax);
|
||||
Assert.AreEqual("000", result.Mobile);
|
||||
Assert.AreEqual("Test", result.Name);
|
||||
Assert.AreEqual("111", result.Telephone);
|
||||
Assert.AreEqual(_webSite.Content, result.WebSite.Content);
|
||||
Assert.AreEqual(_webSite.Media, result.WebSite.Media);
|
||||
Assert.AreEqual(_webSite.OpenInNewWindow, result.WebSite.OpenInNewWindow);
|
||||
Assert.AreEqual(_webSite.Title, result.WebSite.Title);
|
||||
Assert.AreEqual(_webSite.Url, result.WebSite.Url);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_ArchetypeJson_To_AnnualStatementModel()
|
||||
{
|
||||
var result = ConvertArchetypeJsonToModel<AnnualStatement>(JsonTestStrings._ANNUAL_STATEMENT_JSON);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.IsInstanceOf<AnnualStatement>(result);
|
||||
|
||||
Assert.AreEqual(new DateTime(2013, 9, 1), result.FiscalYearStart);
|
||||
Assert.AreEqual(new DateTime(2014, 8, 31), result.FiscalYearEnd);
|
||||
Assert.IsNull(result.DividendPaymentDate);
|
||||
Assert.AreEqual(345678, result.TotalShares);
|
||||
Assert.AreEqual(123456700.89, result.Sales);
|
||||
Assert.AreEqual(1123456.78m, result.Profit);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_ArchetypeJson_To_AnnualStatementModel_NullableDate_HasValue()
|
||||
{
|
||||
var annualStatement = new AnnualStatement
|
||||
{
|
||||
FiscalYearStart = new DateTime(2013, 9, 1),
|
||||
FiscalYearEnd = new DateTime(2014, 8, 31),
|
||||
DividendPaymentDate = new DateTime(2014,9,15,10,15,30),
|
||||
TotalShares = 345678,
|
||||
Sales = 123456700.89,
|
||||
Profit = 1123456.78m
|
||||
};
|
||||
|
||||
var result = ConvertModelToArchetypeAndBack(annualStatement);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.IsInstanceOf<AnnualStatement>(result);
|
||||
|
||||
Assert.AreEqual(annualStatement.FiscalYearStart, result.FiscalYearStart);
|
||||
Assert.AreEqual(annualStatement.FiscalYearEnd, result.FiscalYearEnd);
|
||||
Assert.AreEqual(annualStatement.DividendPaymentDate, result.DividendPaymentDate);
|
||||
Assert.AreEqual(annualStatement.TotalShares, result.TotalShares);
|
||||
Assert.AreEqual(annualStatement.Sales, result.Sales);
|
||||
Assert.AreEqual(annualStatement.Profit, result.Profit);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_ArchetypeJson_To_AllContactDetailsModel()
|
||||
{
|
||||
var item1 = new ContactDetails
|
||||
{
|
||||
Address = "addr",
|
||||
Email = "email"
|
||||
};
|
||||
|
||||
var item2 = new ContactDetails
|
||||
{
|
||||
Address = "addr1",
|
||||
Name = "email2"
|
||||
};
|
||||
|
||||
var model = new AllContactDetails
|
||||
{
|
||||
UserDetails = item1,
|
||||
AdminDetails = item2
|
||||
};
|
||||
|
||||
var result = ConvertModelToArchetypeAndBack(model);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.IsInstanceOf<AllContactDetails>(result);
|
||||
|
||||
Assert.AreEqual(item1.Address, result.UserDetails.Address);
|
||||
Assert.AreEqual(item1.Email, result.UserDetails.Email);
|
||||
Assert.AreEqual(item2.Address, result.AdminDetails.Address);
|
||||
Assert.AreEqual(item2.Name, result.AdminDetails.Name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_ArchetypeJson_To_ContactDetailsListModel()
|
||||
{
|
||||
var item1 = new ContactDetails
|
||||
{
|
||||
Address = "addr",
|
||||
Email = "email"
|
||||
};
|
||||
|
||||
var item2 = new ContactDetails
|
||||
{
|
||||
Address = "addr1",
|
||||
Name = "email2"
|
||||
};
|
||||
|
||||
var model = new ContactDetailsList
|
||||
{
|
||||
item1,
|
||||
item2
|
||||
};
|
||||
|
||||
var result = ConvertModelToArchetypeAndBack(model);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.IsInstanceOf<ContactDetailsList>(result);
|
||||
Assert.AreEqual(result.Count, 2);
|
||||
|
||||
Assert.AreEqual(item1.Address, result[0].Address);
|
||||
Assert.AreEqual(item1.Email, result[0].Email);
|
||||
Assert.AreEqual(item2.Address, result[1].Address);
|
||||
Assert.AreEqual(item2.Name, result[1].Name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_ArchetypeJson_To_CompanyDetailsModel()
|
||||
{
|
||||
var model = new CompanyDetails
|
||||
{
|
||||
Region = "Test Region",
|
||||
ContactDetails = new ContactDetails
|
||||
{
|
||||
Address = "addr1",
|
||||
Name = "email2"
|
||||
}
|
||||
};
|
||||
|
||||
var result = ConvertModelToArchetypeAndBack(model);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.IsInstanceOf<CompanyDetails>(result);
|
||||
|
||||
Assert.AreEqual(model.Region, result.Region);
|
||||
Assert.AreEqual(model.ContactDetails.Address, result.ContactDetails.Address);
|
||||
Assert.AreEqual(model.ContactDetails.Name, result.ContactDetails.Name);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
-206
@@ -1,206 +0,0 @@
|
||||
using System.Linq;
|
||||
using Archetype.Tests.Serialization.Base;
|
||||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Archetype.Tests.Serialization.UseCases.Complex
|
||||
{
|
||||
[TestFixture]
|
||||
public class ArchetypeJsonConverterTest : ArchetypeJsonConverterTestBase
|
||||
{
|
||||
private TextList _textList;
|
||||
private Captions _captions;
|
||||
private PageDetails _pageDetails;
|
||||
|
||||
private SlideShow _slides;
|
||||
private Seo _seo;
|
||||
private TextPageList _textPages;
|
||||
private PageList _pages;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
InitComplexModels();
|
||||
InitComplexTreeModel();
|
||||
}
|
||||
|
||||
#region complex nested model tests
|
||||
|
||||
[Test]
|
||||
public void Convert_PageDetailsModel_To_ArchetypeJson()
|
||||
{
|
||||
var result = ConvertModelToArchetypeJson(_pageDetails, Formatting.Indented);
|
||||
Assert.AreEqual(JsonTestStrings._PAGE_DETAILS_JSON, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_PageDetailsModel_To_Archetype()
|
||||
{
|
||||
Assert.NotNull(ConvertModelToArchetype(_pageDetails));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_ArchetypeJson_To_PageDetailsModel()
|
||||
{
|
||||
var result = ConvertArchetypeJsonToModel<PageDetails>(JsonTestStrings._PAGE_DETAILS_JSON);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.IsInstanceOf<PageDetails>(result);
|
||||
|
||||
Assert.AreEqual("2439,2440,2441,2442,2443,2444,2445,2446,2447,2448,2449,2450,2451,2452,2453", result.Pages);
|
||||
Assert.AreEqual("First Page", result.Captions.TextStringArray.ElementAt(0).TextString);
|
||||
Assert.AreEqual("Second Page", result.Captions.TextStringArray.ElementAt(1).TextString);
|
||||
Assert.AreEqual("Third Page", result.Captions.TextStringArray.ElementAt(2).TextString);
|
||||
Assert.AreEqual("Fourth Page", result.Captions.TextStringArray.ElementAt(3).TextString);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_PageDetailsModel_To_Archetype_AndBack()
|
||||
{
|
||||
var result = ConvertModelToArchetypeAndBack(_pageDetails);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.IsInstanceOf<PageDetails>(result);
|
||||
|
||||
Assert.AreEqual(_pageDetails.Pages, result.Pages);
|
||||
Assert.AreEqual(_pageDetails.Captions.TextStringArray.ElementAt(0).TextString, result.Captions.TextStringArray.ElementAt(0).TextString);
|
||||
Assert.AreEqual(_pageDetails.Captions.TextStringArray.ElementAt(1).TextString, result.Captions.TextStringArray.ElementAt(1).TextString);
|
||||
Assert.AreEqual(_pageDetails.Captions.TextStringArray.ElementAt(2).TextString, result.Captions.TextStringArray.ElementAt(2).TextString);
|
||||
Assert.AreEqual(_pageDetails.Captions.TextStringArray.ElementAt(3).TextString, result.Captions.TextStringArray.ElementAt(3).TextString);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region complex nested tree model tests
|
||||
|
||||
[Test]
|
||||
public void Convert_PagesModel_To_Archetype()
|
||||
{
|
||||
Assert.NotNull(ConvertModelToArchetype(_pages));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_PagesModel_To_ArchetypeJson()
|
||||
{
|
||||
var result = ConvertModelToArchetypeJson(_pages, Formatting.Indented);
|
||||
Assert.AreEqual(JsonTestStrings._PAGES_JSON, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_ArchetypeJson_To_PagesModel()
|
||||
{
|
||||
var result = ConvertArchetypeJsonToModel<PageList>(JsonTestStrings._PAGES_JSON);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.IsInstanceOf<PageList>(result);
|
||||
|
||||
Assert.AreEqual("1,2,3,4,5,6,7,8", result.Pages.ElementAt(0).Media.Slides);
|
||||
Assert.AreEqual("1,2,3,4,5,6,7,8", result.Pages.ElementAt(1).Media.Slides);
|
||||
Assert.AreEqual("1,2,3,4,5,6,7,8", result.Pages.ElementAt(2).Media.Slides);
|
||||
|
||||
Assert.AreEqual("Test Meta Title", result.Pages.ElementAt(0).Seo.MetaTitle);
|
||||
Assert.AreEqual("Test Meta Description", result.Pages.ElementAt(0).Seo.MetaDescription);
|
||||
Assert.AreEqual("Test Meta Title", result.Pages.ElementAt(1).Seo.MetaTitle);
|
||||
Assert.AreEqual("Test Meta Description", result.Pages.ElementAt(1).Seo.MetaDescription);
|
||||
Assert.AreEqual("Test Meta Title", result.Pages.ElementAt(2).Seo.MetaTitle);
|
||||
Assert.AreEqual("Test Meta Description", result.Pages.ElementAt(2).Seo.MetaDescription);
|
||||
|
||||
Assert.AreEqual("Home Page Body", result.Pages.ElementAt(0).BodyText);
|
||||
Assert.AreEqual("Home Page", result.Pages.ElementAt(0).PageTitle);
|
||||
Assert.AreEqual("About us Page Body", result.Pages.ElementAt(1).BodyText);
|
||||
Assert.AreEqual("About us Page", result.Pages.ElementAt(1).PageTitle);
|
||||
Assert.AreEqual("Contact us Page Body", result.Pages.ElementAt(2).BodyText);
|
||||
Assert.AreEqual("Contact us Page", result.Pages.ElementAt(2).PageTitle);
|
||||
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_PagesModel_To_Archetype_AndBack()
|
||||
{
|
||||
var result = ConvertModelToArchetypeAndBack(_pages);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.IsInstanceOf<PageList>(result);
|
||||
|
||||
Assert.AreEqual(_pages.Pages.ElementAt(0).Media.Slides, result.Pages.ElementAt(0).Media.Slides);
|
||||
Assert.AreEqual(_pages.Pages.ElementAt(1).Media.Slides, result.Pages.ElementAt(1).Media.Slides);
|
||||
Assert.AreEqual(_pages.Pages.ElementAt(2).Media.Slides, result.Pages.ElementAt(2).Media.Slides);
|
||||
|
||||
Assert.AreEqual(_pages.Pages.ElementAt(0).Seo.MetaTitle, result.Pages.ElementAt(0).Seo.MetaTitle);
|
||||
Assert.AreEqual(_pages.Pages.ElementAt(0).Seo.MetaDescription, result.Pages.ElementAt(0).Seo.MetaDescription);
|
||||
Assert.AreEqual(_pages.Pages.ElementAt(1).Seo.MetaTitle, result.Pages.ElementAt(1).Seo.MetaTitle);
|
||||
Assert.AreEqual(_pages.Pages.ElementAt(1).Seo.MetaDescription, result.Pages.ElementAt(1).Seo.MetaDescription);
|
||||
Assert.AreEqual(_pages.Pages.ElementAt(2).Seo.MetaTitle, result.Pages.ElementAt(2).Seo.MetaTitle);
|
||||
Assert.AreEqual(_pages.Pages.ElementAt(2).Seo.MetaDescription, result.Pages.ElementAt(2).Seo.MetaDescription);
|
||||
|
||||
Assert.AreEqual(_pages.Pages.ElementAt(0).BodyText, result.Pages.ElementAt(0).BodyText);
|
||||
Assert.AreEqual(_pages.Pages.ElementAt(0).PageTitle, result.Pages.ElementAt(0).PageTitle);
|
||||
Assert.AreEqual(_pages.Pages.ElementAt(1).BodyText, result.Pages.ElementAt(1).BodyText);
|
||||
Assert.AreEqual(_pages.Pages.ElementAt(1).PageTitle, result.Pages.ElementAt(1).PageTitle);
|
||||
Assert.AreEqual(_pages.Pages.ElementAt(2).BodyText, result.Pages.ElementAt(2).BodyText);
|
||||
Assert.AreEqual(_pages.Pages.ElementAt(2).PageTitle, result.Pages.ElementAt(2).PageTitle);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region utility methods
|
||||
|
||||
private void InitComplexModels()
|
||||
{
|
||||
_textList = new TextList
|
||||
{
|
||||
new TextItem{TextString = "First Page"},
|
||||
new TextItem{TextString = "Second Page"},
|
||||
new TextItem{TextString = "Third Page"},
|
||||
new TextItem{TextString = "Fourth Page"}
|
||||
};
|
||||
|
||||
_captions = new Captions {TextStringArray = _textList};
|
||||
|
||||
_pageDetails = new PageDetails
|
||||
{
|
||||
Captions = _captions,
|
||||
Pages = "2439,2440,2441,2442,2443,2444,2445,2446,2447,2448,2449,2450,2451,2452,2453"
|
||||
};
|
||||
}
|
||||
|
||||
private void InitComplexTreeModel()
|
||||
{
|
||||
_slides = new SlideShow{Slides = "1,2,3,4,5,6,7,8"};
|
||||
_seo = new Seo{MetaDescription = "Test Meta Description", MetaTitle = "Test Meta Title"};
|
||||
_textPages = new TextPageList
|
||||
{
|
||||
new TextPage()
|
||||
{
|
||||
PageTitle = "Home Page",
|
||||
BodyText = "Home Page Body",
|
||||
Media = _slides,
|
||||
Seo = _seo
|
||||
},
|
||||
new TextPage()
|
||||
{
|
||||
PageTitle = "About us Page",
|
||||
BodyText = "About us Page Body",
|
||||
Media = _slides,
|
||||
Seo = _seo
|
||||
},
|
||||
new TextPage()
|
||||
{
|
||||
PageTitle = "Contact us Page",
|
||||
BodyText = "Contact us Page Body",
|
||||
Media = _slides,
|
||||
Seo = _seo
|
||||
}
|
||||
};
|
||||
|
||||
_pages = new PageList
|
||||
{
|
||||
Pages = _textPages
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Archetype.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Archetype.Tests.Serialization.UseCases.Complex
|
||||
{
|
||||
#region complex nested model
|
||||
|
||||
[AsArchetype("pages")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class PageDetails
|
||||
{
|
||||
[JsonProperty("pages")]
|
||||
public string Pages { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("captions")]
|
||||
public Captions Captions { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("captions")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class Captions
|
||||
{
|
||||
[JsonProperty("captions")]
|
||||
public TextList TextStringArray { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("textstringArray")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class TextList : List<TextItem>
|
||||
{
|
||||
}
|
||||
|
||||
[AsArchetype("textstringArray")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class TextItem
|
||||
{
|
||||
[JsonProperty("textstring")]
|
||||
public string TextString { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region complex nested tree model
|
||||
|
||||
public abstract class PageBase
|
||||
{
|
||||
public string PageTitle { get; set; }
|
||||
public string BodyText { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("slideShow")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class SlideShow
|
||||
{
|
||||
public string Slides { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("seo")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class Seo
|
||||
{
|
||||
public string MetaTitle { get; set; }
|
||||
public string MetaDescription { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("TextPage")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class TextPage : PageBase
|
||||
{
|
||||
[AsFieldset]
|
||||
public SlideShow Media { get; set; }
|
||||
|
||||
[AsFieldset]
|
||||
public Seo Seo { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("TextPageList")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class TextPageList : List<TextPage>
|
||||
{
|
||||
}
|
||||
|
||||
[AsArchetype("Pages")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class PageList
|
||||
{
|
||||
public TextPageList Pages { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,245 +0,0 @@
|
||||
namespace Archetype.Tests.Serialization.UseCases.Complex
|
||||
{
|
||||
public class JsonTestStrings
|
||||
{
|
||||
public const string _PAGE_DETAILS_JSON =
|
||||
@"{
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""captions"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""captions"",
|
||||
""value"": {
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""captions"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""captions"",
|
||||
""value"": {
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""textstringArray"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""textstring"",
|
||||
""value"": ""First Page""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""alias"": ""textstringArray"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""textstring"",
|
||||
""value"": ""Second Page""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""alias"": ""textstringArray"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""textstring"",
|
||||
""value"": ""Third Page""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""alias"": ""textstringArray"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""textstring"",
|
||||
""value"": ""Fourth Page""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""alias"": ""pages"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""pages"",
|
||||
""value"": ""2439,2440,2441,2442,2443,2444,2445,2446,2447,2448,2449,2450,2451,2452,2453""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}";
|
||||
|
||||
public const string _PAGES_JSON =
|
||||
@"{
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""Pages"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""Pages"",
|
||||
""value"": {
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""TextPage"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""Media"",
|
||||
""value"": {
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""slideShow"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""Slides"",
|
||||
""value"": ""1,2,3,4,5,6,7,8""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
""alias"": ""Seo"",
|
||||
""value"": {
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""seo"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""MetaTitle"",
|
||||
""value"": ""Test Meta Title""
|
||||
},
|
||||
{
|
||||
""alias"": ""MetaDescription"",
|
||||
""value"": ""Test Meta Description""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
""alias"": ""PageTitle"",
|
||||
""value"": ""Home Page""
|
||||
},
|
||||
{
|
||||
""alias"": ""BodyText"",
|
||||
""value"": ""Home Page Body""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""alias"": ""TextPage"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""Media"",
|
||||
""value"": {
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""slideShow"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""Slides"",
|
||||
""value"": ""1,2,3,4,5,6,7,8""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
""alias"": ""Seo"",
|
||||
""value"": {
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""seo"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""MetaTitle"",
|
||||
""value"": ""Test Meta Title""
|
||||
},
|
||||
{
|
||||
""alias"": ""MetaDescription"",
|
||||
""value"": ""Test Meta Description""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
""alias"": ""PageTitle"",
|
||||
""value"": ""About us Page""
|
||||
},
|
||||
{
|
||||
""alias"": ""BodyText"",
|
||||
""value"": ""About us Page Body""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""alias"": ""TextPage"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""Media"",
|
||||
""value"": {
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""slideShow"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""Slides"",
|
||||
""value"": ""1,2,3,4,5,6,7,8""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
""alias"": ""Seo"",
|
||||
""value"": {
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""seo"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""MetaTitle"",
|
||||
""value"": ""Test Meta Title""
|
||||
},
|
||||
{
|
||||
""alias"": ""MetaDescription"",
|
||||
""value"": ""Test Meta Description""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
""alias"": ""PageTitle"",
|
||||
""value"": ""Contact us Page""
|
||||
},
|
||||
{
|
||||
""alias"": ""BodyText"",
|
||||
""value"": ""Contact us Page Body""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}";
|
||||
}
|
||||
}
|
||||
-143
@@ -1,143 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Archetype.Models;
|
||||
using Archetype.PropertyConverters;
|
||||
using Archetype.Tests.Serialization.Base;
|
||||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Archetype.Tests.Serialization.UseCases.Enumerable
|
||||
{
|
||||
[TestFixture]
|
||||
public class ArchetypeJsonConverterTest : ArchetypeJsonConverterTestBase
|
||||
{
|
||||
private Feedbacks _feedbacks;
|
||||
private Captions _captions;
|
||||
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_feedbacks = new Feedbacks
|
||||
{
|
||||
new Feedback{Testimonial = "Testimonial 1"},
|
||||
new Feedback{Testimonial = "Testimonial 2"},
|
||||
new Feedback{Testimonial = "Testimonial 3"}
|
||||
};
|
||||
|
||||
_captions = new Captions()
|
||||
{
|
||||
TextArray = new List<Text>
|
||||
{
|
||||
new Text{TextString = "Caption 1"},
|
||||
new Text{TextString = "Caption 2"},
|
||||
new Text{TextString = "Caption 3"}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#region Feedback - single fieldset with multiple items
|
||||
|
||||
[Test]
|
||||
public void Convert_FeedbackModel_To_Archetype()
|
||||
{
|
||||
var converter = new ArchetypeValueConverter();
|
||||
var json = JsonConvert.SerializeObject(_feedbacks);
|
||||
var archetype = (ArchetypeModel)converter.ConvertDataToSource(null, json, false);
|
||||
|
||||
Assert.NotNull(archetype);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_FeedbackModel_To_ArchetypeJson()
|
||||
{
|
||||
var json = ConvertModelToArchetypeJson(_feedbacks, Formatting.Indented);
|
||||
Assert.AreEqual(JsonTestStrings._FEEDBACK_JSON, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_ArchetypeJson_To_FeedbackModel()
|
||||
{
|
||||
var result = ConvertArchetypeJsonToModel<Feedbacks>(JsonTestStrings._FEEDBACK_JSON);
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(3, result.Count);
|
||||
|
||||
foreach (var feedback in result)
|
||||
{
|
||||
Assert.AreEqual(String.Format("Testimonial {0}", result.IndexOf(feedback) + 1),
|
||||
feedback.Testimonial);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_FeedbackModel_To_Archetype_AndBack()
|
||||
{
|
||||
var result = ConvertModelToArchetypeAndBack(_feedbacks);
|
||||
Assert.NotNull(result);
|
||||
|
||||
Assert.AreEqual(3, result.Count);
|
||||
|
||||
foreach (var feedback in result)
|
||||
{
|
||||
var index = result.IndexOf(feedback);
|
||||
Assert.AreEqual(_feedbacks.ElementAt(index).Testimonial, feedback.Testimonial);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Captions - a root fieldset which contains another fieldset list
|
||||
|
||||
[Test]
|
||||
public void Convert_CaptionsModel_To_Archetype()
|
||||
{
|
||||
var converter = new ArchetypeValueConverter();
|
||||
var json = JsonConvert.SerializeObject(_captions);
|
||||
var archetype = (ArchetypeModel)converter.ConvertDataToSource(null, json, false);
|
||||
|
||||
Assert.NotNull(archetype);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_CaptionsModel_To_ArchetypeJson()
|
||||
{
|
||||
var json = ConvertModelToArchetypeJson(_captions, Formatting.Indented);
|
||||
Assert.AreEqual(JsonTestStrings._CAPTIONS_JSON, json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_ArchetypeJson_To_CaptionsModel()
|
||||
{
|
||||
var result = ConvertArchetypeJsonToModel<Captions>(JsonTestStrings._CAPTIONS_JSON);
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.TextArray);
|
||||
|
||||
Assert.AreEqual(3, result.TextArray.Count);
|
||||
|
||||
foreach (var caption in result.TextArray)
|
||||
{
|
||||
Assert.AreEqual(String.Format("Caption {0}", result.TextArray.IndexOf(caption) + 1),
|
||||
caption.TextString);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Convert_CaptionsModel_To_Archetype_AndBack()
|
||||
{
|
||||
var result = ConvertModelToArchetypeAndBack(_captions);
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.TextArray);
|
||||
|
||||
Assert.AreEqual(3, result.TextArray.Count);
|
||||
|
||||
foreach (var caption in result.TextArray)
|
||||
{
|
||||
var index = result.TextArray.IndexOf(caption);
|
||||
Assert.AreEqual(_captions.TextArray.ElementAt(index).TextString, caption.TextString);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Archetype.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Archetype.Tests.Serialization.UseCases.Enumerable
|
||||
{
|
||||
#region Feedback - single fieldset with multiple items
|
||||
|
||||
[AsArchetype("feedbacks")] /* Note: when inheriting from a list, archetype alias is not used */
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class Feedbacks : List<Feedback>
|
||||
{
|
||||
}
|
||||
|
||||
[AsArchetype("feedback")] /* Must have same archetype alias as list class */
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class Feedback
|
||||
{
|
||||
[JsonProperty("testimonial")]
|
||||
public String Testimonial { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Captions - a root fieldset which contains another fieldset list
|
||||
|
||||
[AsArchetype("captions")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class Captions
|
||||
{
|
||||
[JsonProperty("captions")]
|
||||
public List<Text> TextArray { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("textArray")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class Text
|
||||
{
|
||||
[JsonProperty("textstring")]
|
||||
public String TextString { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
[AsArchetype("aboutUs")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class AboutUs
|
||||
{
|
||||
[AsFieldset]
|
||||
[JsonProperty("contacts")]
|
||||
public IEnumerable<ContactDetails> Contacts { get; set; }
|
||||
[AsFieldset]
|
||||
[JsonProperty("testimonials")]
|
||||
public IEnumerable<String> Testimonials { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
namespace Archetype.Tests.Serialization.UseCases.Enumerable
|
||||
{
|
||||
public class JsonTestStrings
|
||||
{
|
||||
public const string _ABOUT_US_JSON =
|
||||
@"";
|
||||
|
||||
public const string _FEEDBACK_JSON =
|
||||
@"{
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""feedback"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""testimonial"",
|
||||
""value"": ""Testimonial 1""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""alias"": ""feedback"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""testimonial"",
|
||||
""value"": ""Testimonial 2""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""alias"": ""feedback"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""testimonial"",
|
||||
""value"": ""Testimonial 3""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}";
|
||||
|
||||
public const string _CAPTIONS_JSON =
|
||||
@"{
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""captions"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""captions"",
|
||||
""value"": {
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""textArray"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""textstring"",
|
||||
""value"": ""Caption 1""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""alias"": ""textArray"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""textstring"",
|
||||
""value"": ""Caption 2""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""alias"": ""textArray"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""textstring"",
|
||||
""value"": ""Caption 3""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}";
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Archetype.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Archetype.Tests.Serialization.UseCases
|
||||
{
|
||||
#region json test Models
|
||||
|
||||
[AsArchetype("urlPicker")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class UrlPicker
|
||||
{
|
||||
[JsonProperty("title")]
|
||||
public string Title { get; set; }
|
||||
[JsonProperty("url")]
|
||||
public string Url { get; set; }
|
||||
[JsonProperty("content")]
|
||||
public int? Content { get; set; }
|
||||
[JsonProperty("media")]
|
||||
public int? Media { get; set; }
|
||||
[JsonProperty("openInNewWindow")]
|
||||
public bool OpenInNewWindow { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("contactDetails")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class ContactDetails
|
||||
{
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
[JsonProperty("address")]
|
||||
public string Address { get; set; }
|
||||
[JsonProperty("telephone")]
|
||||
public string Telephone { get; set; }
|
||||
[JsonProperty("mobile")]
|
||||
public string Mobile { get; set; }
|
||||
[JsonProperty("fax")]
|
||||
public string Fax { get; set; }
|
||||
[JsonProperty("email")]
|
||||
public string Email { get; set; }
|
||||
[JsonProperty("webSite")]
|
||||
public UrlPicker WebSite { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("companyDetails")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class CompanyDetails
|
||||
{
|
||||
[JsonProperty("region")]
|
||||
public string Region { get; set; }
|
||||
[JsonProperty("contactDetails")]
|
||||
public ContactDetails ContactDetails { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("allContactDetails")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class AllContactDetails
|
||||
{
|
||||
public ContactDetails UserDetails { get; set; }
|
||||
public ContactDetails AdminDetails { get; set; }
|
||||
|
||||
}
|
||||
|
||||
[AsArchetype("contactDetailsList")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class ContactDetailsList : List<ContactDetails>
|
||||
{
|
||||
}
|
||||
|
||||
[AsArchetype("annualStatement")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class AnnualStatement
|
||||
{
|
||||
public DateTime FiscalYearStart { get; set; }
|
||||
public DateTime FiscalYearEnd { get; set; }
|
||||
public DateTime? DividendPaymentDate { get; set; }
|
||||
public Int32 TotalShares { get; set; }
|
||||
public Double Sales { get; set; }
|
||||
public Decimal Profit { get; set; }
|
||||
}
|
||||
|
||||
[AsArchetype("mergerDetails")]
|
||||
[JsonConverter(typeof(ArchetypeJsonConverter))]
|
||||
public class MergerDetails
|
||||
{
|
||||
public DateTime MergerDate { get; set; }
|
||||
[JsonIgnore]
|
||||
public decimal MergerValue { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,207 +0,0 @@
|
||||
namespace Archetype.Tests.Serialization.UseCases
|
||||
{
|
||||
public class JsonTestStrings
|
||||
{
|
||||
public const string _MERGER_DETAILS_JSON =
|
||||
@"{
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""mergerDetails"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""MergerDate"",
|
||||
""value"": ""07/06/2014 08:09:10""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}";
|
||||
|
||||
public const string _ANNUAL_STATEMENT_JSON =
|
||||
@"{
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""annualStatement"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""FiscalYearStart"",
|
||||
""value"": ""01/09/2013 00:00:00""
|
||||
},
|
||||
{
|
||||
""alias"": ""FiscalYearEnd"",
|
||||
""value"": ""31/08/2014 00:00:00""
|
||||
},
|
||||
{
|
||||
""alias"": ""DividendPaymentDate"",
|
||||
""value"": """"
|
||||
},
|
||||
{
|
||||
""alias"": ""TotalShares"",
|
||||
""value"": ""345678""
|
||||
},
|
||||
{
|
||||
""alias"": ""Sales"",
|
||||
""value"": ""123456700.89""
|
||||
},
|
||||
{
|
||||
""alias"": ""Profit"",
|
||||
""value"": ""1123456.78""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}";
|
||||
|
||||
public const string _CONTACT_DETAILS_JSON =
|
||||
@"{
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""contactDetails"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""name"",
|
||||
""value"": ""Test""
|
||||
},
|
||||
{
|
||||
""alias"": ""address"",
|
||||
""value"": ""Test Address""
|
||||
},
|
||||
{
|
||||
""alias"": ""telephone"",
|
||||
""value"": ""111""
|
||||
},
|
||||
{
|
||||
""alias"": ""mobile"",
|
||||
""value"": ""000""
|
||||
},
|
||||
{
|
||||
""alias"": ""fax"",
|
||||
""value"": ""000""
|
||||
},
|
||||
{
|
||||
""alias"": ""email"",
|
||||
""value"": ""test@test.com""
|
||||
},
|
||||
{
|
||||
""alias"": ""webSite"",
|
||||
""value"": {
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""urlPicker"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""title"",
|
||||
""value"": ""The Test Company""
|
||||
},
|
||||
{
|
||||
""alias"": ""url"",
|
||||
""value"": ""http://test.com""
|
||||
},
|
||||
{
|
||||
""alias"": ""content"",
|
||||
""value"": """"
|
||||
},
|
||||
{
|
||||
""alias"": ""media"",
|
||||
""value"": """"
|
||||
},
|
||||
{
|
||||
""alias"": ""openInNewWindow"",
|
||||
""value"": ""1""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}";
|
||||
|
||||
public const string _COMPANY_DETAILS_JSON =
|
||||
@"{
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""companyDetails"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""region"",
|
||||
""value"": ""Test Region""
|
||||
},
|
||||
{
|
||||
""alias"": ""contactDetails"",
|
||||
""value"": {
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""contactDetails"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""name"",
|
||||
""value"": ""Test""
|
||||
},
|
||||
{
|
||||
""alias"": ""address"",
|
||||
""value"": ""Test Address""
|
||||
},
|
||||
{
|
||||
""alias"": ""telephone"",
|
||||
""value"": ""111""
|
||||
},
|
||||
{
|
||||
""alias"": ""mobile"",
|
||||
""value"": ""000""
|
||||
},
|
||||
{
|
||||
""alias"": ""fax"",
|
||||
""value"": ""000""
|
||||
},
|
||||
{
|
||||
""alias"": ""email"",
|
||||
""value"": ""test@test.com""
|
||||
},
|
||||
{
|
||||
""alias"": ""webSite"",
|
||||
""value"": {
|
||||
""fieldsets"": [
|
||||
{
|
||||
""alias"": ""urlPicker"",
|
||||
""properties"": [
|
||||
{
|
||||
""alias"": ""title"",
|
||||
""value"": ""The Test Company""
|
||||
},
|
||||
{
|
||||
""alias"": ""url"",
|
||||
""value"": ""http://test.com""
|
||||
},
|
||||
{
|
||||
""alias"": ""content"",
|
||||
""value"": """"
|
||||
},
|
||||
{
|
||||
""alias"": ""media"",
|
||||
""value"": """"
|
||||
},
|
||||
{
|
||||
""alias"": ""openInNewWindow"",
|
||||
""value"": ""1""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}";
|
||||
|
||||
public const string _NULL_VALUES_JSON = @"{""fieldsets"":[{""alias"":""contactDetails"",""properties"":[{""alias"":""name"",""value"":""""},{""alias"":""address"",""value"":""""},{""alias"":""telephone"",""value"":""""},{""alias"":""mobile"",""value"":""""},{""alias"":""fax"",""value"":""""},{""alias"":""email"",""value"":""""},{""alias"":""webSite"",""value"":""""}]}]}";
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<settings>
|
||||
|
||||
<!--
|
||||
umbracoSettings.config configuration documentation can be found here:
|
||||
http://our.umbraco.org/documentation/using-umbraco/config-files/umbracoSettings/
|
||||
Many of the optional settings are not explicitly listed here
|
||||
but can be found in the online documentation.
|
||||
-->
|
||||
|
||||
<content>
|
||||
|
||||
<errors>
|
||||
<error404>1</error404>
|
||||
<!--
|
||||
<error404>
|
||||
<errorPage culture="default">1</errorPage>
|
||||
<errorPage culture="en-US">200</errorPage>
|
||||
</error404>
|
||||
-->
|
||||
</errors>
|
||||
|
||||
<notifications>
|
||||
<!-- the email that should be used as from mail when umbraco sends a notification -->
|
||||
<email>your@email.here</email>
|
||||
</notifications>
|
||||
|
||||
<!-- Show property descriptions in editing view "icon|text|none" -->
|
||||
<PropertyContextHelpOption>text</PropertyContextHelpOption>
|
||||
|
||||
<!-- The html injected into a (x)html page if Umbraco is running in preview mode -->
|
||||
<PreviewBadge><![CDATA[<a id="umbracoPreviewBadge" style="position: absolute; top: 0; right: 0; border: 0; width: 149px; height: 149px; background: url('{1}/preview/previewModeBadge.png') no-repeat;" href="{0}/endPreview.aspx?redir={2}"><span style="display:none;">In Preview Mode - click to end</span></a>]]></PreviewBadge>
|
||||
|
||||
<!-- Cache cycle of Media and Member data fetched from the umbraco.library methods -->
|
||||
<!-- In seconds. 0 will disable cache -->
|
||||
<UmbracoLibraryCacheDuration>1800</UmbracoLibraryCacheDuration>
|
||||
|
||||
<!-- How Umbraco should handle errors during macro execution. Can be one of the following values:
|
||||
- inline - show an inline error within the macro but allow the page to continue rendering. Historial Umbraco behaviour.
|
||||
- silent - Silently suppress the error and do not render the offending macro.
|
||||
- throw - Throw an exception which can be caught by the global error handler defined in Application_OnError. If no such
|
||||
error handler is defined then you'll see the Yellow Screen Of Death (YSOD) error page.
|
||||
Note the error can also be handled by the umbraco.macro.Error event, where you can log/alarm with your own code and change the behaviour per event. -->
|
||||
<MacroErrors>inline</MacroErrors>
|
||||
|
||||
<!-- These file types will not be allowed to be uploaded via the upload control for media and content -->
|
||||
<disallowedUploadFiles>ashx,aspx,ascx,config,cshtml,vbhtml,asmx,air,axd</disallowedUploadFiles>
|
||||
|
||||
<!-- Defines the default document type property used when adding properties in the back-office (if missing or empty, defaults to Textstring -->
|
||||
<defaultDocumentTypeProperty>Textstring</defaultDocumentTypeProperty>
|
||||
</content>
|
||||
|
||||
<security>
|
||||
<!-- set to true to auto update login interval (and there by disabling the lock screen -->
|
||||
<keepUserLoggedIn>false</keepUserLoggedIn>
|
||||
<!-- change in 4.8: Disabled users are now showed dimmed and last in the tree. If you prefer not to display them set this to true -->
|
||||
<hideDisabledUsersInBackoffice>false</hideDisabledUsersInBackoffice>
|
||||
</security>
|
||||
|
||||
<requestHandler>
|
||||
<!-- this will ensure that urls are unique when running with multiple root nodes -->
|
||||
<useDomainPrefixes>false</useDomainPrefixes>
|
||||
<!-- this will add a trailing slash (/) to urls when in directory url mode -->
|
||||
<addTrailingSlash>true</addTrailingSlash>
|
||||
</requestHandler>
|
||||
|
||||
<templates>
|
||||
<!-- To switch the default rendering engine to MVC, change this value from WebForms to Mvc -->
|
||||
<defaultRenderingEngine>Mvc</defaultRenderingEngine>
|
||||
</templates>
|
||||
|
||||
<scheduledTasks>
|
||||
<!-- add tasks that should be called with an interval (seconds) -->
|
||||
<!-- <task log="true" alias="test60" interval="60" url="http://localhost/umbraco/test.aspx"/>-->
|
||||
</scheduledTasks>
|
||||
|
||||
<!-- distributed calls make umbraco use webservices to handle cache refreshing -->
|
||||
<distributedCall enable="false">
|
||||
<!-- the id of the user who's making the calls -->
|
||||
<!-- needed for security, umbraco will automatically look up correct login and passwords -->
|
||||
<user>0</user>
|
||||
<servers>
|
||||
<!-- add ip number or hostname, make sure that it can be reached from all servers -->
|
||||
<!-- you can also add optional attributes to force a protocol or port number (see #2) -->
|
||||
<!-- <server>127.0.0.1</server>-->
|
||||
<!-- <server forceProtocol="http|https" forcePortnumber="80|443">127.0.0.1</server>-->
|
||||
</servers>
|
||||
</distributedCall>
|
||||
|
||||
<!--
|
||||
web.routing
|
||||
@trySkipIisCustomErrors
|
||||
Tries to skip IIS custom errors.
|
||||
Starting with IIS 7.5, this must be set to true for Umbraco 404 pages to show. Else, IIS will take
|
||||
over and render its build-in error page. See MS doc for HttpResponseBase.TrySkipIisCustomErrors.
|
||||
The default value is false, for backward compatibility reasons, which means that IIS _will_ take
|
||||
over, and _prevent_ Umbraco 404 pages to show.
|
||||
@internalRedirectPreservesTemplate
|
||||
By default as soon as we're not displaying the initial document, we reset the template set by the
|
||||
finder or by the alt. template. Set this option to true to preserve the template set by the finder
|
||||
or by the alt. template, in case of an internal redirect.
|
||||
(false by default, and in fact should remain false unless you know what you're doing)
|
||||
-->
|
||||
<web.routing
|
||||
trySkipIisCustomErrors="false"
|
||||
internalRedirectPreservesTemplate="false">
|
||||
</web.routing>
|
||||
|
||||
</settings>
|
||||
@@ -21,7 +21,7 @@
|
||||
<package id="Moq" version="4.2.1312.1622" targetFramework="net45" />
|
||||
<package id="MySql.Data" version="6.6.5" targetFramework="net45" />
|
||||
<package id="Newtonsoft.Json" version="6.0.2" targetFramework="net45" />
|
||||
<package id="NUnit" version="2.6.3" targetFramework="net45" />
|
||||
<package id="NUnit" version="2.6.4" targetFramework="net45" />
|
||||
<package id="SharpZipLib" version="0.86.0" targetFramework="net45" />
|
||||
<package id="UmbracoCms.Core" version="7.1.2" targetFramework="net45" />
|
||||
<package id="xmlrpcnet" version="2.5.0" targetFramework="net45" />
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
using System;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
namespace DatabaseSizer
|
||||
{
|
||||
public class Application : ApplicationEventHandler
|
||||
{
|
||||
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
base.ApplicationStarted(umbracoApplication, applicationContext);
|
||||
|
||||
ExpandPrevalueValueColumnSize();
|
||||
}
|
||||
|
||||
protected void ExpandPrevalueValueColumnSize()
|
||||
{
|
||||
try
|
||||
{
|
||||
var dbContext = ApplicationContext.Current.DatabaseContext;
|
||||
var colCount =
|
||||
dbContext.Database.ExecuteScalar<int>(
|
||||
"SELECT COUNT(1) FROM INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE = 'nvarchar' AND COLUMN_NAME = 'value' AND CHARACTER_MAXIMUM_LENGTH = 2500 AND TABLE_NAME = 'cmsDataTypePreValues'");
|
||||
|
||||
// Check column
|
||||
if (colCount != 0)
|
||||
{
|
||||
using (var trans = dbContext.Database.GetTransaction())
|
||||
{
|
||||
// Change column
|
||||
dbContext.Database.Execute("ALTER TABLE [cmsDataTypePreValues] ALTER COLUMN [value] ntext NULL;");
|
||||
|
||||
trans.Complete();
|
||||
}
|
||||
|
||||
LogHelper.Debug(typeof(Application), "Successfully expanded Prevalue table Value column");
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.Debug(typeof(Application), "Prevalue table Value column is already expanded");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error(typeof(Application), "Error expanding Prevalue table Value column", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,213 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{0114C963-C514-49C1-B7AB-DCB1825F498C}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DatabaseSizer</RootNamespace>
|
||||
<AssemblyName>DatabaseSizer</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AutoMapper">
|
||||
<HintPath>..\packages\AutoMapper.3.0.0\lib\net40\AutoMapper.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AutoMapper.Net4">
|
||||
<HintPath>..\packages\AutoMapper.3.0.0\lib\net40\AutoMapper.Net4.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="businesslogic">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\businesslogic.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ClientDependency.Core">
|
||||
<HintPath>..\packages\ClientDependency.1.7.1.2\lib\ClientDependency.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ClientDependency.Core.Mvc">
|
||||
<HintPath>..\packages\ClientDependency-Mvc.1.7.0.4\lib\ClientDependency.Core.Mvc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="cms">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\cms.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="controls">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\controls.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="CookComputing.XmlRpcV2">
|
||||
<HintPath>..\packages\xmlrpcnet.2.5.0\lib\net20\CookComputing.XmlRpcV2.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Examine">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\Examine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HtmlAgilityPack">
|
||||
<HintPath>..\packages\HtmlAgilityPack.1.4.6\lib\Net45\HtmlAgilityPack.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ICSharpCode.SharpZipLib">
|
||||
<HintPath>..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ImageProcessor">
|
||||
<HintPath>..\packages\ImageProcessor.1.9.0.0\lib\ImageProcessor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ImageProcessor.Web">
|
||||
<HintPath>..\packages\ImageProcessor.Web.3.2.3.0\lib\net45\ImageProcessor.Web.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="interfaces">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\interfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="log4net">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Lucene.Net">
|
||||
<HintPath>..\packages\Lucene.Net.2.9.4.1\lib\net40\Lucene.Net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ApplicationBlocks.Data">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\Microsoft.ApplicationBlocks.Data.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Helpers">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\Microsoft.Web.Helpers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Mvc.FixedDisplayModes">
|
||||
<HintPath>..\packages\Microsoft.AspNet.Mvc.FixedDisplayModes.1.0.0\lib\net40\Microsoft.Web.Mvc.FixedDisplayModes.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MiniProfiler">
|
||||
<HintPath>..\packages\MiniProfiler.2.1.0\lib\net40\MiniProfiler.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MySql.Data">
|
||||
<HintPath>..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\packages\Newtonsoft.Json.6.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SQLCE4Umbraco">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\SQLCE4Umbraco.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\System.Data.SqlServerCe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.SqlServerCe.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\System.Data.SqlServerCe.Entity.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.4.0.30506.0\lib\net40\System.Net.Http.Formatting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.Helpers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.4.0.20710.0\lib\net40\System.Web.Http.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebApi.WebHost.4.0.20710.0\lib\net40\System.Web.Http.WebHost.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\Microsoft.AspNet.Mvc.4.0.20710.0\lib\net40\System.Web.Mvc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\Microsoft.AspNet.Razor.2.0.20710.0\lib\net40\System.Web.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Deployment.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="TidyNet">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\TidyNet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="umbraco">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\umbraco.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Umbraco.Core">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\Umbraco.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="umbraco.DataLayer">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\umbraco.DataLayer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="umbraco.editorControls">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\umbraco.editorControls.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="umbraco.MacroEngines">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\umbraco.MacroEngines.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="umbraco.providers">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\umbraco.providers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Umbraco.Web.UI">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\Umbraco.Web.UI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="umbraco.XmlSerializers">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\umbraco.XmlSerializers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UmbracoExamine">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\UmbracoExamine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UrlRewritingNet.UrlRewriter">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\UrlRewritingNet.UrlRewriter.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Application.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -1,36 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("DatabaseSizer.cs")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("DatabaseSizer.cs")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("28dc35d2-3dfb-40b4-9093-bc47c91127ea")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -1,6 +1,8 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.40629.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Archetype.Umbraco", "Umbraco.Archetype\Archetype.Umbraco.csproj", "{7D185D41-4228-4978-ACB8-83F9A48AD94F}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{D84AA4ED-85A6-484F-9E72-BE7AC9835821}"
|
||||
@@ -12,7 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{D84AA4
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Archetype.Tests", "Archetype.Tests\Archetype.Tests.csproj", "{21F3E6CF-B76F-4059-9474-1AF1CE63CD6B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DatabaseSizer", "DatabaseSizer\DatabaseSizer.csproj", "{0114C963-C514-49C1-B7AB-DCB1825F498C}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Archetype.Courier", "Archetype.Courier\Archetype.Courier.csproj", "{FE8BE437-8B11-4E49-9B02-F45994E6D723}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -28,10 +30,10 @@ Global
|
||||
{21F3E6CF-B76F-4059-9474-1AF1CE63CD6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{21F3E6CF-B76F-4059-9474-1AF1CE63CD6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{21F3E6CF-B76F-4059-9474-1AF1CE63CD6B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0114C963-C514-49C1-B7AB-DCB1825F498C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0114C963-C514-49C1-B7AB-DCB1825F498C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0114C963-C514-49C1-B7AB-DCB1825F498C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0114C963-C514-49C1-B7AB-DCB1825F498C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FE8BE437-8B11-4E49-9B02-F45994E6D723}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FE8BE437-8B11-4E49-9B02-F45994E6D723}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FE8BE437-8B11-4E49-9B02-F45994E6D723}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FE8BE437-8B11-4E49-9B02-F45994E6D723}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -8,26 +8,41 @@ using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.Editors;
|
||||
using Archetype.Extensions;
|
||||
using Archetype.Models;
|
||||
|
||||
namespace Archetype.Api
|
||||
{
|
||||
/// <summary>
|
||||
/// Controller that handles datatype related interactions.
|
||||
/// </summary>
|
||||
/// <seealso cref="Umbraco.Web.Editors.UmbracoAuthorizedJsonController" />
|
||||
[PluginController("ArchetypeApi")]
|
||||
public class ArchetypeDataTypeController : UmbracoAuthorizedJsonController
|
||||
{
|
||||
|
||||
public IEnumerable<object> GetAllPropertyEditors()
|
||||
{
|
||||
return
|
||||
global::Umbraco.Core.PropertyEditors.PropertyEditorResolver.Current.PropertyEditors
|
||||
.Select(x => new {defaultPreValues = x.DefaultPreValues, alias = x.Alias, view = x.ValueEditor.View});
|
||||
.Select(x => new { defaultPreValues = x.DefaultPreValuesForArchetype(), alias = x.Alias, view = x.ValueEditor.View });
|
||||
}
|
||||
|
||||
public object GetAll()
|
||||
/// <summary>
|
||||
/// Gets all datatypes.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public object GetAll()
|
||||
{
|
||||
var dataTypes = Services.DataTypeService.GetAllDataTypeDefinitions();
|
||||
return dataTypes.Select(t => new { guid = t.Key, name = t.Name });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the datatype by GUID.
|
||||
/// </summary>
|
||||
/// <param name="guid">The unique identifier.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="System.Web.Http.HttpResponseException"></exception>
|
||||
public object GetByGuid(Guid guid)
|
||||
{
|
||||
var dataType = Services.DataTypeService.GetDataTypeDefinitionById(guid);
|
||||
@@ -35,8 +50,93 @@ namespace Archetype.Api
|
||||
{
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
}
|
||||
|
||||
var dataTypeDisplay = Mapper.Map<IDataTypeDefinition, DataTypeDisplay>(dataType);
|
||||
return new { selectedEditor = dataTypeDisplay.SelectedEditor, preValues = dataTypeDisplay.PreValues };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the datatype by GUID.
|
||||
/// </summary>
|
||||
/// <param name="guid">The unique identifier.</param>
|
||||
/// <param name="contentTypeAlias">The content type alias.</param>
|
||||
/// <param name="propertyTypeAlias">The property type alias.</param>
|
||||
/// <param name="archetypeAlias">The archetype alias.</param>
|
||||
/// <param name="nodeId">The node identifier.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="System.Web.Http.HttpResponseException"></exception>
|
||||
public object GetByGuid(Guid guid, string contentTypeAlias, string propertyTypeAlias, string archetypeAlias, int nodeId)
|
||||
{
|
||||
var dataType = Services.DataTypeService.GetDataTypeDefinitionById(guid);
|
||||
|
||||
if (dataType == null)
|
||||
{
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
}
|
||||
|
||||
var dataTypeDisplay = Mapper.Map<IDataTypeDefinition, DataTypeDisplay>(dataType);
|
||||
|
||||
return new { selectedEditor = dataTypeDisplay.SelectedEditor, preValues = dataTypeDisplay.PreValues, contentTypeAlias = contentTypeAlias, propertyTypeAlias = propertyTypeAlias, archetypeAlias = archetypeAlias, nodeId = nodeId };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the DLL version from the file.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public object GetDllVersion()
|
||||
{
|
||||
return new { dllVersion = ArchetypeHelper.Instance.DllVersion() };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Globals the settings.
|
||||
/// </summary>
|
||||
/// <returns>System.Object.</returns>
|
||||
[HttpGet]
|
||||
public object GlobalSettings()
|
||||
{
|
||||
return new
|
||||
{
|
||||
isCheckingForUpdates = ArchetypeGlobalSettings.Instance.CheckForUpdates
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the check for updates.
|
||||
/// </summary>
|
||||
/// <param name="isChecking">if set to <c>true</c> [is checking].</param>
|
||||
[HttpPost]
|
||||
public void SetCheckForUpdates([FromBody] bool isChecking)
|
||||
{
|
||||
ArchetypeGlobalSettings.Instance.CheckForUpdates = isChecking;
|
||||
ArchetypeGlobalSettings.Instance.Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks for updates.
|
||||
/// </summary>
|
||||
/// <returns>System.Object.</returns>
|
||||
[HttpPost]
|
||||
public object CheckForUpdates()
|
||||
{
|
||||
if (!ArchetypeGlobalSettings.Instance.CheckForUpdates)
|
||||
{
|
||||
return new
|
||||
{
|
||||
isUpdateAvailable = false
|
||||
};
|
||||
}
|
||||
|
||||
var updateNotificationModel = ArchetypeHelper.Instance.CheckForUpdates();
|
||||
|
||||
return new
|
||||
{
|
||||
isUpdateAvailable = updateNotificationModel.IsUpdateAvailable,
|
||||
headline = updateNotificationModel.Headline,
|
||||
type = updateNotificationModel.Type,
|
||||
message = updateNotificationModel.Message,
|
||||
url = updateNotificationModel.Url
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
@@ -129,6 +129,7 @@
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
@@ -231,23 +232,32 @@
|
||||
<Compile Include="Api\ArchetypeDataTypeController.cs" />
|
||||
<Compile Include="Constants.cs" />
|
||||
<Compile Include="Events\ExpireCache.cs" />
|
||||
<Compile Include="Extensions\ArchetypeFieldsetModelExtensions.cs" />
|
||||
<Compile Include="Extensions\ArchetypeHelper.cs" />
|
||||
<Compile Include="Extensions\Extensions.cs" />
|
||||
<Compile Include="Extensions\ArchetypeModelExtensions.cs" />
|
||||
<Compile Include="Extensions\HtmlHelperExtensions.cs" />
|
||||
<Compile Include="Extensions\ArchetypePropertyModelExtensions.cs" />
|
||||
<Compile Include="Extensions\PropertyEditorExtensions.cs" />
|
||||
<Compile Include="Extensions\StringExtensions.cs" />
|
||||
<Compile Include="Models\ArchetypeConfigFileModel.cs" />
|
||||
<Compile Include="Models\ArchetypeGlobalSettings.cs" />
|
||||
<Compile Include="Models\ArchetypeModel.cs" />
|
||||
<Compile Include="Models\ArchetypePreValue.cs" />
|
||||
<Compile Include="Models\ArchetypePreValueFieldset.cs" />
|
||||
<Compile Include="Models\ArchetypePreValueFieldsetGroup.cs" />
|
||||
<Compile Include="Models\ArchetypePreValueProperty.cs" />
|
||||
<Compile Include="Models\ArchetypeFieldsetModel.cs" />
|
||||
<Compile Include="Models\ArchetypePropertyModel.cs" />
|
||||
<Compile Include="Models\ArchetypePublishedContent.cs" />
|
||||
<Compile Include="Models\ArchetypePublishedContentSet.cs" />
|
||||
<Compile Include="Models\ArchetypePublishedProperty.cs" />
|
||||
<Compile Include="Models\ArchetypeUpdateNotification.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\VersionInfo.cs" />
|
||||
<Compile Include="PropertyConverters\ArchetypeValueConverter.cs" />
|
||||
<Compile Include="Serialization\ArchetypeJsonDelinter.cs" />
|
||||
<Compile Include="Serialization\AsArchetypeAttribute.cs" />
|
||||
<Compile Include="PropertyEditors\ArchetypePropertyEditor.cs" />
|
||||
<Compile Include="Serialization\ArchetypeJsonConverter.cs" />
|
||||
<Compile Include="Serialization\AsFieldsetAttribute.cs" />
|
||||
<Compile Include="Serialization\SerializationExtensions.cs" />
|
||||
<Compile Include="TypeConverters\ArchetypeFieldsetModelConverter.cs" />
|
||||
<Compile Include="TypeConverters\ArchetypeModelConverter.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
namespace Archetype
|
||||
{
|
||||
/// <summary>
|
||||
/// Archetype constants.
|
||||
/// </summary>
|
||||
public static class Constants
|
||||
{
|
||||
public const string PropertyEditorAlias = "Imulus.Archetype";
|
||||
@@ -9,5 +12,8 @@
|
||||
public const string CacheKey_DataTypeByGuid = "";
|
||||
|
||||
public const string CacheKey_PreValueFromDataTypeId = "Archetype_GetArchetypePreValueFromDataTypeId_";
|
||||
|
||||
public const string UmbracoVersionAlias = "umbracoConfigurationStatus";
|
||||
public const string NotificationUrl = "https://api.gizmo42.com/v1/archetype/check-for-updates";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web;
|
||||
|
||||
namespace Archetype.Events
|
||||
{
|
||||
public class ExpireCache : ApplicationEventHandler
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Registers our ExpirePreValueCache handler on app starting.
|
||||
/// </summary>
|
||||
/// <param name="umbracoApplication"></param>
|
||||
/// <param name="applicationContext"></param>
|
||||
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
base.ApplicationStarting(umbracoApplication, applicationContext);
|
||||
@@ -20,6 +18,11 @@ namespace Archetype.Events
|
||||
DataTypeService.Saved += ExpirePreValueCache;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Expires the pre value cache when a datatype is saved.
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e">The <see cref="Umbraco.Core.Events.SaveEventArgs{IDataTypeDefinition}"/> instance containing the event data.</param>
|
||||
void ExpirePreValueCache(IDataTypeService sender, global::Umbraco.Core.Events.SaveEventArgs<IDataTypeDefinition> e)
|
||||
{
|
||||
foreach (var dataType in e.SavedEntities)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Linq;
|
||||
using Archetype.Models;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Archetype.Extensions
|
||||
{
|
||||
public static class ArchetypeFieldsetModelExtensions
|
||||
{
|
||||
public static IPublishedContent ToPublishedContent(this ArchetypeFieldsetModel fieldset)
|
||||
{
|
||||
return new ArchetypePublishedContent(fieldset);
|
||||
}
|
||||
|
||||
public static IPublishedContent ToPublishedContent(this ArchetypeFieldsetModel fieldset, ArchetypeModel archetype)
|
||||
{
|
||||
var contentSet = archetype.ToPublishedContentSet();
|
||||
|
||||
var first = contentSet
|
||||
.Cast<ArchetypePublishedContent>()
|
||||
.FirstOrDefault(x => x.ArchetypeFieldset == fieldset);
|
||||
|
||||
return first ?? new ArchetypePublishedContent(fieldset);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,96 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using Archetype.Models;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using System.Reflection;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
|
||||
/// <summary>
|
||||
/// The Extensions namespace.
|
||||
/// </summary>
|
||||
namespace Archetype.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper class that handles several Archetype related interactions.
|
||||
/// </summary>
|
||||
public class ArchetypeHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// The json settings
|
||||
/// </summary>
|
||||
protected JsonSerializerSettings _jsonSettings;
|
||||
/// <summary>
|
||||
/// The application
|
||||
/// </summary>
|
||||
protected ApplicationContext _app;
|
||||
/// <summary>
|
||||
/// The pad lock
|
||||
/// </summary>
|
||||
private static readonly object _padLock = new object();
|
||||
/// <summary>
|
||||
/// The instance
|
||||
/// </summary>
|
||||
private static ArchetypeHelper _instance = new ArchetypeHelper();
|
||||
|
||||
private static readonly ArchetypeHelper _instance = new ArchetypeHelper();
|
||||
/// <summary>
|
||||
/// Gets the instance.
|
||||
/// </summary>
|
||||
/// <value>The instance.</value>
|
||||
internal static ArchetypeHelper Instance {
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
lock (_padLock)
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new ArchetypeHelper();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static ArchetypeHelper Instance { get { return _instance; } }
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
internal ArchetypeHelper()
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ArchetypeHelper" /> class.
|
||||
/// </summary>
|
||||
private ArchetypeHelper()
|
||||
{
|
||||
var dcr = new Newtonsoft.Json.Serialization.DefaultContractResolver();
|
||||
dcr.DefaultMembersSearchFlags |= System.Reflection.BindingFlags.NonPublic;
|
||||
dcr.DefaultMembersSearchFlags |= BindingFlags.NonPublic;
|
||||
|
||||
_jsonSettings = new JsonSerializerSettings { ContractResolver = dcr };
|
||||
_app = ApplicationContext.Current;
|
||||
}
|
||||
|
||||
internal Models.ArchetypeModel DeserializeJsonToArchetype(string sourceJson, PreValueCollection dataTypePreValues)
|
||||
/// <summary>
|
||||
/// Gets the json serializer settings.
|
||||
/// </summary>
|
||||
/// <value>The json serializer settings.</value>
|
||||
internal JsonSerializerSettings JsonSerializerSettings { get { return _jsonSettings; } }
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the JSON to archetype.
|
||||
/// </summary>
|
||||
/// <param name="sourceJson">The source JSON.</param>
|
||||
/// <param name="dataTypePreValues">The data type pre values.</param>
|
||||
/// <returns>ArchetypeModel.</returns>
|
||||
internal ArchetypeModel DeserializeJsonToArchetype(string sourceJson, PreValueCollection dataTypePreValues)
|
||||
{
|
||||
try
|
||||
{
|
||||
var archetype = JsonConvert.DeserializeObject<Models.ArchetypeModel>(sourceJson, _jsonSettings);
|
||||
var archetype = JsonConvert.DeserializeObject<ArchetypeModel>(sourceJson, _jsonSettings);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -40,21 +100,29 @@ namespace Archetype.Extensions
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<ArchetypeHelper>("DeserializeJsonToArchetype", ex);
|
||||
}
|
||||
|
||||
return archetype;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new Models.ArchetypeModel();
|
||||
return new ArchetypeModel();
|
||||
}
|
||||
}
|
||||
|
||||
internal Models.ArchetypeModel DeserializeJsonToArchetype(string sourceJson, int dataTypeId, PublishedContentType hostContentType = null)
|
||||
/// <summary>
|
||||
/// Deserializes the JSON to archetype.
|
||||
/// </summary>
|
||||
/// <param name="sourceJson">The source JSON.</param>
|
||||
/// <param name="dataTypeId">The data type identifier.</param>
|
||||
/// <param name="hostContentType">Type of the host content.</param>
|
||||
/// <returns>ArchetypeModel.</returns>
|
||||
internal ArchetypeModel DeserializeJsonToArchetype(string sourceJson, int dataTypeId, PublishedContentType hostContentType = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var archetype = JsonConvert.DeserializeObject<Models.ArchetypeModel>(sourceJson, _jsonSettings);
|
||||
var archetype = JsonConvert.DeserializeObject<ArchetypeModel>(sourceJson, _jsonSettings);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -64,16 +132,81 @@ namespace Archetype.Extensions
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<ArchetypeHelper>(string.Format("DeserializeJsonToArchetype Error DatatypeId=>{0} SourceJson=>{1}", dataTypeId, sourceJson), ex);
|
||||
}
|
||||
|
||||
return archetype;
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new Models.ArchetypeModel();
|
||||
return new ArchetypeModel();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether datatypeId has had it's PVC overridden.
|
||||
/// </summary>
|
||||
/// <param name="dataTypeId">The data type identifier.</param>
|
||||
/// <returns><c>true</c> if [is property value converter overridden] [the specified data type identifier]; otherwise, <c>false</c>.</returns>
|
||||
internal bool IsPropertyValueConverterOverridden(int dataTypeId)
|
||||
{
|
||||
var prevalues = GetArchetypePreValueFromDataTypeId(dataTypeId);
|
||||
|
||||
if (prevalues == null)
|
||||
return false;
|
||||
|
||||
return prevalues.OverrideDefaultPropertyValueConverter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks for updates.
|
||||
/// </summary>
|
||||
/// <returns>ArchetypeUpdateNotification.</returns>
|
||||
internal ArchetypeUpdateNotification CheckForUpdates()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
var content = new StringContent(JsonConvert.SerializeObject(new
|
||||
{
|
||||
umbracoVersion = ConfigurationManager.AppSettings[Constants.UmbracoVersionAlias],
|
||||
archetypeVersion = DllVersion(),
|
||||
id = ArchetypeGlobalSettings.Instance.Id
|
||||
}), Encoding.UTF8, "application/json");
|
||||
|
||||
client.DefaultRequestHeaders.Add("x-api-key-id", ArchetypeGlobalSettings.Instance.ApiKey.ToString());
|
||||
|
||||
var response = client.PostAsync(new Uri(Constants.NotificationUrl), content).Result;
|
||||
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
var responseString = response.Content.ReadAsStringAsync().Result;
|
||||
|
||||
return JsonConvert.DeserializeObject<ArchetypeUpdateNotification>(responseString);
|
||||
}
|
||||
|
||||
return new ArchetypeUpdateNotification
|
||||
{
|
||||
IsUpdateAvailable = false
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//if anything goes wrong let's make sure we don't break their site
|
||||
return new ArchetypeUpdateNotification
|
||||
{
|
||||
IsUpdateAvailable = false
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the archetype pre value from data type identifier.
|
||||
/// </summary>
|
||||
/// <param name="dataTypeId">The data type identifier.</param>
|
||||
/// <returns>ArchetypePreValue.</returns>
|
||||
private ArchetypePreValue GetArchetypePreValueFromDataTypeId(int dataTypeId)
|
||||
{
|
||||
return _app.ApplicationCache.RuntimeCache.GetCacheItem(
|
||||
@@ -94,6 +227,11 @@ namespace Archetype.Extensions
|
||||
}) as ArchetypePreValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the archetype pre value from pre values collection.
|
||||
/// </summary>
|
||||
/// <param name="dataTypePreValues">The data type pre values.</param>
|
||||
/// <returns>ArchetypePreValue.</returns>
|
||||
private ArchetypePreValue GetArchetypePreValueFromPreValuesCollection(PreValueCollection dataTypePreValues)
|
||||
{
|
||||
var preValueAsString = dataTypePreValues.PreValuesAsDictionary.First().Value.Value;
|
||||
@@ -101,7 +239,12 @@ namespace Archetype.Extensions
|
||||
return preValue;
|
||||
}
|
||||
|
||||
private IDataTypeDefinition GetDataTypeByGuid(Guid guid)
|
||||
/// <summary>
|
||||
/// Gets the data type by unique identifier.
|
||||
/// </summary>
|
||||
/// <param name="guid">The unique identifier.</param>
|
||||
/// <returns>IDataTypeDefinition.</returns>
|
||||
internal IDataTypeDefinition GetDataTypeByGuid(Guid guid)
|
||||
{
|
||||
return (IDataTypeDefinition)ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem(
|
||||
Constants.CacheKey_DataTypeByGuid + guid,
|
||||
@@ -113,7 +256,8 @@ namespace Archetype.Extensions
|
||||
/// </summary>
|
||||
/// <param name="archetype">The Archetype to add the additional metadata to</param>
|
||||
/// <param name="preValue">The configuration of the Archetype</param>
|
||||
private void RetrieveAdditionalProperties(ref Models.ArchetypeModel archetype, ArchetypePreValue preValue, PublishedContentType hostContentType = null)
|
||||
/// <param name="hostContentType">Type of the host content.</param>
|
||||
private void RetrieveAdditionalProperties(ref ArchetypeModel archetype, ArchetypePreValue preValue, PublishedContentType hostContentType = null)
|
||||
{
|
||||
foreach (var fieldset in preValue.Fieldsets)
|
||||
{
|
||||
@@ -138,9 +282,8 @@ namespace Archetype.Extensions
|
||||
/// <summary>
|
||||
/// Retrieves additional metadata that isn't available on the stored model of an ArchetypePreValue
|
||||
/// </summary>
|
||||
/// <param name="archetype">The Archetype to add the additional metadata to</param>
|
||||
/// <param name="preValue">The configuration of the Archetype</param>
|
||||
private void RetrieveAdditionalProperties(ref Models.ArchetypePreValue preValue)
|
||||
private void RetrieveAdditionalProperties(ref ArchetypePreValue preValue)
|
||||
{
|
||||
foreach (var fieldset in preValue.Fieldsets)
|
||||
{
|
||||
@@ -150,5 +293,18 @@ namespace Archetype.Extensions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the DLL version from the file.
|
||||
/// </summary>
|
||||
/// <returns>System.String.</returns>
|
||||
internal string DllVersion()
|
||||
{
|
||||
var asm = Assembly.GetExecutingAssembly();
|
||||
var fvi = FileVersionInfo.GetVersionInfo(asm.Location);
|
||||
|
||||
return fvi.FileVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using Archetype.Models;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Archetype.Extensions
|
||||
{
|
||||
public static class ArchetypeModelExtensions
|
||||
{
|
||||
public static IEnumerable<IPublishedContent> ToPublishedContentSet(this ArchetypeModel archetype)
|
||||
{
|
||||
return new ArchetypePublishedContentSet(archetype);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using Archetype.Models;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
|
||||
namespace Archetype.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// ArchetypePropertyModel extensions.
|
||||
/// </summary>
|
||||
public static class ArchetypePropertyModelExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines whether this instance is an archetype.
|
||||
/// </summary>
|
||||
/// <param name="prop">The property.</param>
|
||||
/// <returns></returns>
|
||||
public static bool IsArchetype(this ArchetypePropertyModel prop)
|
||||
{
|
||||
return prop.PropertyEditorAlias.InvariantEquals(Constants.PropertyEditorAlias);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates dummy property type.
|
||||
/// </summary>
|
||||
/// <param name="prop">The property.</param>
|
||||
/// <returns></returns>
|
||||
internal static PublishedPropertyType CreateDummyPropertyType(this ArchetypePropertyModel prop)
|
||||
{
|
||||
// We need to check if `PropertyValueConvertersResolver` exists,
|
||||
// otherwise `PublishedPropertyType` will throw an exception outside of the Umbraco context.; e.g. unit-tests.
|
||||
if (!PropertyValueConvertersResolver.HasCurrent)
|
||||
return null;
|
||||
|
||||
return new PublishedPropertyType(prop.HostContentType, new PropertyType(new DataTypeDefinition(-1, prop.PropertyEditorAlias) { Id = prop.DataTypeId }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc.Html;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Web;
|
||||
using Archetype.Models;
|
||||
|
||||
namespace Archetype.Extensions
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
//lifted from the core as it is marked 'internal'
|
||||
public static bool DetectIsJson(this string input)
|
||||
{
|
||||
input = input.Trim();
|
||||
return input.StartsWith("{") && input.EndsWith("}")
|
||||
|| input.StartsWith("[") && input.EndsWith("]");
|
||||
}
|
||||
|
||||
public static bool IsArchetype(this ArchetypePropertyModel prop)
|
||||
{
|
||||
return prop.PropertyEditorAlias.InvariantEquals(Constants.PropertyEditorAlias);
|
||||
}
|
||||
|
||||
public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel)
|
||||
{
|
||||
return RenderPartials(htmlHelper, archetypeModel, null, null);
|
||||
}
|
||||
|
||||
public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath)
|
||||
{
|
||||
return RenderPartials(htmlHelper, archetypeModel, partialPath, null);
|
||||
}
|
||||
|
||||
public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, ViewDataDictionary viewDataDictionary)
|
||||
{
|
||||
return RenderPartials(htmlHelper, archetypeModel, null, viewDataDictionary);
|
||||
}
|
||||
|
||||
public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath, ViewDataDictionary viewDataDictionary)
|
||||
{
|
||||
return RenderPartials(htmlHelper, archetypeModel, partialPath, viewDataDictionary);
|
||||
}
|
||||
|
||||
private static IHtmlString RenderPartials(HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath, ViewDataDictionary viewDataDictionary)
|
||||
{
|
||||
var context = HttpContext.Current;
|
||||
|
||||
if (archetypeModel == null || context == null)
|
||||
{
|
||||
return new HtmlString("");
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
|
||||
var pathToPartials = "~/Views/Partials/Archetype/";
|
||||
if (!string.IsNullOrEmpty(partialPath))
|
||||
{
|
||||
pathToPartials = partialPath;
|
||||
}
|
||||
|
||||
foreach (var fieldsetModel in archetypeModel)
|
||||
{
|
||||
var partial = pathToPartials + fieldsetModel.Alias + ".cshtml";
|
||||
|
||||
if (System.IO.File.Exists(context.Server.MapPath(partial)))
|
||||
{
|
||||
sb.AppendLine(htmlHelper.Partial(partial, fieldsetModel, viewDataDictionary).ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.Info<ArchetypeModel>(string.Format("The partial for {0} could not be found. Please create a partial with that name or rename your alias.", context.Server.MapPath(partial)));
|
||||
}
|
||||
}
|
||||
|
||||
return new HtmlString(sb.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc.Html;
|
||||
using Archetype.Models;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
namespace Archetype.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// HtmlHelper extenions used for rendering an Archetype.
|
||||
/// </summary>
|
||||
public static class HtmlHelperExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Renders the partials based on the model, partial path and given viewdata dictionary.
|
||||
/// </summary>
|
||||
/// <param name="htmlHelper">The HTML helper.</param>
|
||||
/// <param name="archetypeModel">The archetype model.</param>
|
||||
/// <param name="partialPath">The partial path.</param>
|
||||
/// <param name="viewDataDictionary">The view data dictionary.</param>
|
||||
/// <returns></returns>
|
||||
private static IHtmlString _renderPartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath, ViewDataDictionary viewDataDictionary)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
foreach (var fieldsetModel in archetypeModel)
|
||||
{
|
||||
sb.AppendLine(_renderPartial(htmlHelper, fieldsetModel, partialPath, viewDataDictionary).ToString());
|
||||
}
|
||||
|
||||
return new HtmlString(sb.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the fieldset partial
|
||||
/// </summary>
|
||||
/// <param name="htmlHelper">The HTML helper.</param>
|
||||
/// <param name="fieldsetModel"></param>
|
||||
/// <param name="partialPath">The partial path.</param>
|
||||
/// <param name="viewDataDictionary">The view data dictionary.</param>
|
||||
/// <returns></returns>
|
||||
private static IHtmlString _renderPartial(HtmlHelper htmlHelper, ArchetypeFieldsetModel fieldsetModel, string partialPath, ViewDataDictionary viewDataDictionary)
|
||||
{
|
||||
var context = HttpContext.Current;
|
||||
|
||||
if (fieldsetModel == null || context == null)
|
||||
{
|
||||
return new HtmlString("");
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
|
||||
//default
|
||||
var pathToPartials = "~/Views/Partials/Archetype/";
|
||||
|
||||
if (!string.IsNullOrEmpty(partialPath))
|
||||
{
|
||||
pathToPartials = partialPath;
|
||||
}
|
||||
|
||||
var partial = string.Format("{0}{1}.cshtml", pathToPartials, fieldsetModel.Alias);
|
||||
|
||||
if (System.IO.File.Exists(context.Server.MapPath(partial)))
|
||||
{
|
||||
sb.AppendLine(htmlHelper.Partial(partial, fieldsetModel, viewDataDictionary).ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.Info<ArchetypeModel>(string.Format("The partial for {0} could not be found. Please create a partial with that name or rename your alias.", context.Server.MapPath(partial)));
|
||||
}
|
||||
|
||||
return new HtmlString(sb.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders a single archtype partial from a fieldset
|
||||
/// </summary>
|
||||
/// <param name="htmlHelper">The HTML helper.</param>
|
||||
/// <param name="fieldsetModel">The fieldset model.</param>
|
||||
/// <returns></returns>
|
||||
public static IHtmlString RenderArchetypePartial(this HtmlHelper htmlHelper, ArchetypeFieldsetModel fieldsetModel)
|
||||
{
|
||||
return _renderPartial(htmlHelper, fieldsetModel, null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the archetype partial.
|
||||
/// </summary>
|
||||
/// <param name="htmlHelper">The HTML helper.</param>
|
||||
/// <param name="fieldsetModel">The fieldset model.</param>
|
||||
/// <param name="partialView">The partial view.</param>
|
||||
/// <returns></returns>
|
||||
public static IHtmlString RenderArchetypePartial(this HtmlHelper htmlHelper, ArchetypeFieldsetModel fieldsetModel, string partialView)
|
||||
{
|
||||
return _renderPartial(htmlHelper, fieldsetModel, partialView, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the archetype partial.
|
||||
/// </summary>
|
||||
/// <param name="htmlHelper">The HTML helper.</param>
|
||||
/// <param name="fieldsetModel">The fieldset model.</param>
|
||||
/// <param name="partialView">The partial view.</param>
|
||||
/// <param name="viewDataDictionary">The view data dictionary.</param>
|
||||
/// <returns></returns>
|
||||
public static IHtmlString RenderArchetypePartial(this HtmlHelper htmlHelper, ArchetypeFieldsetModel fieldsetModel, string partialView, ViewDataDictionary viewDataDictionary)
|
||||
{
|
||||
return _renderPartial(htmlHelper, fieldsetModel, partialView, viewDataDictionary);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the archetype partials.
|
||||
/// </summary>
|
||||
/// <param name="htmlHelper">The HTML helper.</param>
|
||||
/// <param name="archetypeModel">The archetype model.</param>
|
||||
/// <returns></returns>
|
||||
public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel)
|
||||
{
|
||||
return _renderPartials(htmlHelper, archetypeModel, null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the archetype partials.
|
||||
/// </summary>
|
||||
/// <param name="htmlHelper">The HTML helper.</param>
|
||||
/// <param name="archetypeModel">The archetype model.</param>
|
||||
/// <param name="partialPath">The partial path.</param>
|
||||
/// <returns></returns>
|
||||
public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath)
|
||||
{
|
||||
return _renderPartials(htmlHelper, archetypeModel, partialPath, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the archetype partials.
|
||||
/// </summary>
|
||||
/// <param name="htmlHelper">The HTML helper.</param>
|
||||
/// <param name="archetypeModel">The archetype model.</param>
|
||||
/// <param name="viewDataDictionary">The view data dictionary.</param>
|
||||
/// <returns></returns>
|
||||
public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, ViewDataDictionary viewDataDictionary)
|
||||
{
|
||||
return _renderPartials(htmlHelper, archetypeModel, null, viewDataDictionary);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the archetype partials.
|
||||
/// </summary>
|
||||
/// <param name="htmlHelper">The HTML helper.</param>
|
||||
/// <param name="archetypeModel">The archetype model.</param>
|
||||
/// <param name="partialPath">The partial path.</param>
|
||||
/// <param name="viewDataDictionary">The view data dictionary.</param>
|
||||
/// <returns></returns>
|
||||
public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath, ViewDataDictionary viewDataDictionary)
|
||||
{
|
||||
return htmlHelper._renderPartials(archetypeModel, partialPath, viewDataDictionary);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
|
||||
namespace Archetype.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// PropertyEditor extensions.
|
||||
/// </summary>
|
||||
public static class PropertyEditorExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Formats the default prevalues for a property editor for use within an Archetype clientside context
|
||||
/// </summary>
|
||||
/// <param name="propertyEditor">The property editor</param>
|
||||
/// <returns>The formatted default prevalues</returns>
|
||||
public static IDictionary<string, object> DefaultPreValuesForArchetype(this PropertyEditor propertyEditor)
|
||||
{
|
||||
if (propertyEditor.DefaultPreValues == null || propertyEditor.DefaultPreValues.Any() == false)
|
||||
{
|
||||
return propertyEditor.DefaultPreValues;
|
||||
}
|
||||
var view = propertyEditor.ValueEditor.View.ToLowerInvariant();
|
||||
|
||||
// This is the extension point for default prevalues formatting, in case we need to handle any other
|
||||
// property editors later on. It should be replaced with a switch statement by then, or maybe some fancy
|
||||
// auto discovery of formatters :)
|
||||
if (view == "imagecropper")
|
||||
{
|
||||
propertyEditor.FormatImageCropperDefaultPreValuesForArchetype();
|
||||
}
|
||||
return propertyEditor.DefaultPreValues;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Format the default prevalues of the image cropper property editor
|
||||
/// </summary>
|
||||
/// <param name="propertyEditor"></param>
|
||||
/// <remarks>
|
||||
/// In order for the image cropper to work clientside, we need to make sure it's default prevalue "focalpoint" is returned
|
||||
/// as a JSON object and not as the string it's defined as on the image cropper property editor.
|
||||
/// </remarks>
|
||||
private static void FormatImageCropperDefaultPreValuesForArchetype(this PropertyEditor propertyEditor)
|
||||
{
|
||||
const string focalPointKey = "focalPoint";
|
||||
|
||||
if (propertyEditor.DefaultPreValues.ContainsKey(focalPointKey) == false || propertyEditor.DefaultPreValues[focalPointKey] == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var focalPoint = propertyEditor.DefaultPreValues[focalPointKey].ToString();
|
||||
if (string.IsNullOrEmpty(focalPoint))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// translate the JSON string to a JSON object
|
||||
propertyEditor.DefaultPreValues[focalPointKey] = JsonConvert.DeserializeObject(focalPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace Archetype.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// String extensions.
|
||||
/// </summary>
|
||||
public static class StringExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Detects if the input string is JSON.
|
||||
/// </summary>
|
||||
/// <param name="input">The input.</param>
|
||||
/// <returns></returns>
|
||||
public static bool DetectIsJson(this string input)
|
||||
{
|
||||
input = input.Trim();
|
||||
return input.StartsWith("{") && input.EndsWith("}")
|
||||
|| input.StartsWith("[") && input.EndsWith("]");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace Archetype.Models
|
||||
{
|
||||
public class ArchetypeConfigFileModel
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public bool CheckForUpdates { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Web.Security;
|
||||
using Archetype.TypeConverters;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core;
|
||||
|
||||
namespace Archetype.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Model that represents a fieldset stored as content JSON.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(ArchetypeFieldsetModelConverter))]
|
||||
public class ArchetypeFieldsetModel
|
||||
{
|
||||
[JsonProperty("alias")]
|
||||
@@ -16,6 +24,21 @@ namespace Archetype.Models
|
||||
[JsonProperty("properties")]
|
||||
public IEnumerable<ArchetypePropertyModel> Properties;
|
||||
|
||||
[JsonProperty("id")]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
[JsonProperty("releaseDate")]
|
||||
public DateTime? ReleaseDate { get; set; }
|
||||
|
||||
[JsonProperty("expireDate")]
|
||||
public DateTime? ExpireDate { get; set; }
|
||||
|
||||
[JsonProperty("allowedMemberGroups")]
|
||||
public string AllowedMemberGroups { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ArchetypeFieldsetModel"/> class.
|
||||
/// </summary>
|
||||
public ArchetypeFieldsetModel()
|
||||
{
|
||||
Properties = new List<ArchetypePropertyModel>();
|
||||
@@ -23,16 +46,27 @@ namespace Archetype.Models
|
||||
|
||||
#region Helper Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value and returns as string.
|
||||
/// </summary>
|
||||
/// <param name="propertyAlias">The property alias.</param>
|
||||
/// <returns></returns>
|
||||
public string GetValue(string propertyAlias)
|
||||
{
|
||||
return GetValue<string>(propertyAlias);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value based on the type passed in as a generic.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="propertyAlias">The property alias.</param>
|
||||
/// <returns></returns>
|
||||
public T GetValue<T>(string propertyAlias)
|
||||
{
|
||||
var property = GetProperty(propertyAlias);
|
||||
|
||||
if (IsEmptyProperty(property))
|
||||
if (IsEmptyProperty(property))
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
@@ -45,11 +79,18 @@ namespace Archetype.Models
|
||||
// however, this would require GetValue<T>(string propertyAlias) to call the common implementation
|
||||
// with a default(T) value, which could in theory result in a performance hit, if T for some reason
|
||||
// is costly to instantiate.
|
||||
/// <summary>
|
||||
/// Gets the value.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="propertyAlias">The property alias.</param>
|
||||
/// <param name="defaultValue">The default value.</param>
|
||||
/// <returns></returns>
|
||||
public T GetValue<T>(string propertyAlias, T defaultValue)
|
||||
{
|
||||
var property = GetProperty(propertyAlias);
|
||||
|
||||
if (IsEmptyProperty(property))
|
||||
if (IsEmptyProperty(property))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
@@ -57,16 +98,31 @@ namespace Archetype.Models
|
||||
return property.GetValue<T>();
|
||||
}
|
||||
|
||||
private bool IsEmptyProperty(ArchetypePropertyModel property)
|
||||
/// <summary>
|
||||
/// Determines whether the property is empty.
|
||||
/// </summary>
|
||||
/// <param name="property">The property.</param>
|
||||
/// <returns></returns>
|
||||
private bool IsEmptyProperty(ArchetypePropertyModel property)
|
||||
{
|
||||
return (property == null || property.Value == null || string.IsNullOrEmpty(property.Value.ToString()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified property alias has property.
|
||||
/// </summary>
|
||||
/// <param name="propertyAlias">The property alias.</param>
|
||||
/// <returns></returns>
|
||||
public bool HasProperty(string propertyAlias)
|
||||
{
|
||||
return GetProperty(propertyAlias) != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified property alias has value.
|
||||
/// </summary>
|
||||
/// <param name="propertyAlias">The property alias.</param>
|
||||
/// <returns></returns>
|
||||
public bool HasValue(string propertyAlias)
|
||||
{
|
||||
var property = GetProperty(propertyAlias);
|
||||
@@ -76,12 +132,42 @@ namespace Archetype.Models
|
||||
return !string.IsNullOrEmpty(property.Value.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the property.
|
||||
/// </summary>
|
||||
/// <param name="propertyAlias">The property alias.</param>
|
||||
/// <returns></returns>
|
||||
private ArchetypePropertyModel GetProperty(string propertyAlias)
|
||||
{
|
||||
return Properties.FirstOrDefault(p => p.Alias.InvariantEquals(propertyAlias));
|
||||
}
|
||||
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Is this fieldset disabled, either explicitly or by other means?
|
||||
/// </summary>
|
||||
/// <returns>true if this fieldset is disabled, false otherwise</returns>
|
||||
internal bool IsAvailable()
|
||||
{
|
||||
// explicitly disabled or implicitly disabled through publishing?
|
||||
var disabled = Disabled
|
||||
|| (ReleaseDate.HasValue && ReleaseDate > DateTime.UtcNow)
|
||||
|| (ExpireDate.HasValue && DateTime.UtcNow > ExpireDate);
|
||||
if (disabled)
|
||||
{
|
||||
// yes - the fieldset is not available
|
||||
return false;
|
||||
}
|
||||
// limitation on member group access?
|
||||
if (string.IsNullOrEmpty(AllowedMemberGroups))
|
||||
{
|
||||
// no - the fieldset is available
|
||||
return true;
|
||||
}
|
||||
// maybe - the fieldset is available if the current member is a member of the configured member groups
|
||||
var currentUserGroups = Roles.GetRolesForUser() ?? new string[0];
|
||||
return currentUserGroups.ContainsAny(AllowedMemberGroups.Split(','));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
namespace Archetype.Models
|
||||
{
|
||||
public class ArchetypeGlobalSettings
|
||||
{
|
||||
public bool CheckForUpdates { get; set; }
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public Guid ApiKey = _getApiKey();
|
||||
|
||||
private static ArchetypeGlobalSettings _instance;
|
||||
|
||||
private static string _pathToConfig = @"~/Config/Archetype.config.js";
|
||||
|
||||
private static readonly string _mappedPathToConfig = IOHelper.MapPath(_pathToConfig);
|
||||
|
||||
private static object _padLock = new object();
|
||||
|
||||
private ArchetypeGlobalSettings()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static ArchetypeGlobalSettings Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
lock (_padLock)
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new ArchetypeGlobalSettings();
|
||||
|
||||
_loadSettingsFromConfigFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
lock (_padLock)
|
||||
{
|
||||
//write to JSON
|
||||
var configFileModel = new ArchetypeConfigFileModel
|
||||
{
|
||||
Id = _instance.Id,
|
||||
CheckForUpdates = _instance.CheckForUpdates
|
||||
};
|
||||
|
||||
var serializedJson = JsonConvert.SerializeObject(configFileModel, Formatting.Indented);
|
||||
|
||||
File.WriteAllText(_mappedPathToConfig, serializedJson);
|
||||
}
|
||||
}
|
||||
|
||||
private static void _loadSettingsFromConfigFile()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(_mappedPathToConfig))
|
||||
{
|
||||
//load
|
||||
var deserializedConfigFile = JsonConvert.DeserializeObject<ArchetypeConfigFileModel>(File.ReadAllText(_mappedPathToConfig));
|
||||
|
||||
if (deserializedConfigFile != null)
|
||||
{
|
||||
_instance.Id = deserializedConfigFile.Id;
|
||||
_instance.CheckForUpdates = deserializedConfigFile.CheckForUpdates;
|
||||
}
|
||||
else
|
||||
{
|
||||
_createNewConfigFile("Config file model was null!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_createNewConfigFile("Config file was missing!");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<ArchetypeGlobalSettings>(ex.Message, ex);
|
||||
|
||||
_createNewConfigFile("Exception!");
|
||||
}
|
||||
}
|
||||
|
||||
private static void _createNewConfigFile(string reason)
|
||||
{
|
||||
//write a new file with defaults
|
||||
LogHelper.Info<ArchetypeGlobalSettings>(string.Format("Generating a new config file reason: {0}", reason));
|
||||
|
||||
_instance.Id = Guid.NewGuid();
|
||||
_instance.CheckForUpdates = true;
|
||||
_instance.Save();
|
||||
}
|
||||
|
||||
private static Guid _getApiKey()
|
||||
{
|
||||
//this is just obfuscation and an attempt to keep out most but not the determined hacker
|
||||
var array = new []
|
||||
{
|
||||
"RTA4MUZDRjA=",
|
||||
"NzkzQS1BRDIw",
|
||||
"OTI3QjFDNjkwQTYy",
|
||||
"MjI0OQ=="
|
||||
};
|
||||
|
||||
return new Guid(string.Format("{0}-{1}-{3}-{2}",
|
||||
_decodeBase64(array[0]),
|
||||
_decodeBase64(array[1]),
|
||||
_decodeBase64(array[2]),
|
||||
_decodeBase64(array[3])
|
||||
));
|
||||
}
|
||||
|
||||
private static string _decodeBase64(string input)
|
||||
{
|
||||
return Encoding.UTF8.GetString(Convert.FromBase64String(input));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +1,65 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Archetype.Serialization;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using Archetype.TypeConverters;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Archetype.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Model that represents an entire Archetype.
|
||||
/// </summary>
|
||||
[JsonObject]
|
||||
[TypeConverter(typeof(ArchetypeModelConverter))]
|
||||
public class ArchetypeModel : IEnumerable<ArchetypeFieldsetModel>
|
||||
{
|
||||
[JsonProperty("fieldsets")]
|
||||
internal IEnumerable<ArchetypeFieldsetModel> Fieldsets { get; set; }
|
||||
public IEnumerable<ArchetypeFieldsetModel> Fieldsets { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ArchetypeModel"/> class.
|
||||
/// </summary>
|
||||
public ArchetypeModel()
|
||||
{
|
||||
Fieldsets = new List<ArchetypeFieldsetModel>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an enumerator that iterates through the collection of fieldsets.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// An enumerator that can be used to iterate through the collection.
|
||||
/// </returns>
|
||||
public IEnumerator<ArchetypeFieldsetModel> GetEnumerator()
|
||||
{
|
||||
return this.Fieldsets.Where(f => f.Disabled == false).GetEnumerator();
|
||||
return this.Fieldsets.Where(f => f.IsAvailable()).GetEnumerator();
|
||||
}
|
||||
|
||||
//possibly obsolete?
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return this.GetEnumerator();
|
||||
}
|
||||
|
||||
internal string SerializeForPersistence()
|
||||
/// <summary>
|
||||
/// Serializes for persistence. This should be used for serialization as it cleans up the JSON before saving.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string SerializeForPersistence()
|
||||
{
|
||||
var json = JObject.Parse(JsonConvert.SerializeObject(this));
|
||||
var propertiesToRemove = new String[] { "propertyEditorAlias", "dataTypeId", "dataTypeGuid", "hostContentType" };
|
||||
var json = JObject.Parse(JsonConvert.SerializeObject(this, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }));
|
||||
|
||||
var propertiesToRemove = new String[] { "propertyEditorAlias", "dataTypeId", "dataTypeGuid", "hostContentType", "editorState" };
|
||||
|
||||
json.Descendants().OfType<JProperty>()
|
||||
.Where(p => propertiesToRemove.Contains(p.Name))
|
||||
.ToList()
|
||||
.ForEach(x => x.Remove());
|
||||
|
||||
return json.ToString(Formatting.None).DelintArchetypeJson();
|
||||
return json.ToString(Formatting.None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Archetype.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Model that represents the configured Archetype options.
|
||||
/// </summary>
|
||||
public class ArchetypePreValue
|
||||
{
|
||||
[JsonProperty("showAdvancedOptions")]
|
||||
@@ -12,6 +16,7 @@ namespace Archetype.Models
|
||||
public bool StartWithAddButton { get; set; }
|
||||
|
||||
[JsonProperty("hideFieldsetToolbar")]
|
||||
[Obsolete("This value is no longer used but is kept to prevent breaking changes.")]
|
||||
public bool HideFieldsetToolbar { get; set; }
|
||||
|
||||
[JsonProperty("enableMultipleFieldsets")]
|
||||
@@ -20,21 +25,42 @@ namespace Archetype.Models
|
||||
[JsonProperty("enableCollapsing")]
|
||||
public bool EnableCollapsing { get; set; }
|
||||
|
||||
[JsonProperty("enableMultipleOpen")]
|
||||
public bool EnableMultipleOpen { get; set; }
|
||||
|
||||
[JsonProperty("enableCloning")]
|
||||
public bool EnableCloning { get; set; }
|
||||
|
||||
[JsonProperty("enableDisabling")]
|
||||
public bool EnableDisabling { get; set; }
|
||||
|
||||
[JsonProperty("enablePublishing")]
|
||||
public bool EnablePublishing { get; set; }
|
||||
|
||||
[JsonProperty("enableCrossDragging")]
|
||||
public bool EnableCrossDragging { get; set; }
|
||||
|
||||
[JsonProperty("enableMemberGroups")]
|
||||
public bool EnableMemberGroups { get; set; }
|
||||
|
||||
[JsonProperty("hideFieldsetControls")]
|
||||
public bool HideFieldsetControls { get; set; }
|
||||
|
||||
[JsonProperty("hidePropertyLabel")]
|
||||
public bool HidePropertyLabel { get; set; }
|
||||
|
||||
[JsonProperty("minFieldsets", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public int MinFieldsets { get; set; }
|
||||
|
||||
[JsonProperty("maxFieldsets", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public int MaxFieldsets { get; set; }
|
||||
|
||||
[JsonProperty("fieldsets")]
|
||||
public IEnumerable<ArchetypePreValueFieldset> Fieldsets { get; set; }
|
||||
|
||||
[JsonProperty("fieldsetGroups")]
|
||||
public IEnumerable<ArchetypePreValueFieldsetGroup> FieldsetGroups { get; set; }
|
||||
|
||||
[JsonProperty("hidePropertyLabels")]
|
||||
public bool HidePropertyLabels { get; set; }
|
||||
|
||||
@@ -50,7 +76,13 @@ namespace Archetype.Models
|
||||
[JsonProperty("customViewPath")]
|
||||
public string CustomViewPath { get; set; }
|
||||
|
||||
[JsonProperty("enableDeepDatatypeRequests")]
|
||||
public bool EnableDeepDatatypeRequests { get; set; }
|
||||
|
||||
[JsonProperty("developerMode")]
|
||||
public bool DeveloperMode { get; set; }
|
||||
|
||||
[JsonProperty("overrideDefaultPropertyValueConverter")]
|
||||
public bool OverrideDefaultPropertyValueConverter { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace Archetype.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Model that represents configured Archetype fieldsets.
|
||||
/// </summary>
|
||||
public class ArchetypePreValueFieldset
|
||||
{
|
||||
[JsonProperty("alias")]
|
||||
@@ -23,7 +26,13 @@ namespace Archetype.Models
|
||||
[JsonProperty("label")]
|
||||
public string Label { get; set; }
|
||||
|
||||
[JsonProperty("previewImage")]
|
||||
public string PreviewImage { get; set; }
|
||||
|
||||
[JsonProperty("properties")]
|
||||
public IEnumerable<ArchetypePreValueProperty> Properties { get; set; }
|
||||
|
||||
[JsonProperty("group")]
|
||||
public ArchetypePreValueFieldsetGroup Group { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Archetype.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Model that represents configured groupings of Archetype fieldsets.
|
||||
/// </summary>
|
||||
public class ArchetypePreValueFieldsetGroup
|
||||
{
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,9 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace Archetype.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Model that represents a configured property on an Archetype fieldset.
|
||||
/// </summary>
|
||||
public class ArchetypePreValueProperty
|
||||
{
|
||||
[JsonProperty("alias")]
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Archetype.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Web;
|
||||
|
||||
namespace Archetype.Models
|
||||
{
|
||||
public class ArchetypePropertyModel {
|
||||
/// <summary>
|
||||
/// Model that represents a stored property in Archetype.
|
||||
/// </summary>
|
||||
public class ArchetypePropertyModel
|
||||
{
|
||||
[JsonProperty("alias")]
|
||||
public string Alias { get; internal set; }
|
||||
public string Alias { get; set; }
|
||||
|
||||
[JsonProperty("value")]
|
||||
public object Value { get; internal set; }
|
||||
public object Value { get; set; }
|
||||
|
||||
[JsonProperty("propertyEditorAlias")]
|
||||
public string PropertyEditorAlias { get; internal set; }
|
||||
@@ -25,15 +29,23 @@ namespace Archetype.Models
|
||||
[JsonProperty("dataTypeGuid")]
|
||||
internal string DataTypeGuid { get; set; }
|
||||
|
||||
// container for temporary editor state from the Umbraco backend
|
||||
[JsonProperty("editorState")]
|
||||
internal UmbracoEditorState EditorState { get; set; }
|
||||
|
||||
[JsonProperty("hostContentType")]
|
||||
internal PublishedContentType HostContentType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value based on the type given.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns></returns>
|
||||
public T GetValue<T>()
|
||||
{
|
||||
|
||||
// Try Umbraco's PropertyValueConverters
|
||||
var converters = UmbracoContext.Current != null ? PropertyValueConvertersResolver.Current.Converters : Enumerable.Empty<IPropertyValueConverter>();
|
||||
if (converters.Any())
|
||||
if (!string.IsNullOrWhiteSpace(this.PropertyEditorAlias) && converters.Any())
|
||||
{
|
||||
var convertedAttempt = TryConvertWithPropertyValueConverters<T>(Value, converters);
|
||||
if (convertedAttempt.Success)
|
||||
@@ -52,9 +64,16 @@ namespace Archetype.Models
|
||||
return default(T);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to convert the value with property value converters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <param name="converters">The converters.</param>
|
||||
/// <returns></returns>
|
||||
private Attempt<T> TryConvertWithPropertyValueConverters<T>(object value, IEnumerable<IPropertyValueConverter> converters)
|
||||
{
|
||||
var properyType = CreateDummyPropertyType(DataTypeId, PropertyEditorAlias);
|
||||
var properyType = this.CreateDummyPropertyType();
|
||||
|
||||
// In umbraco, there are default value converters that try to convert the
|
||||
// value if all else fails. The problem is, they are also in the list of
|
||||
@@ -72,6 +91,13 @@ namespace Archetype.Models
|
||||
if (value2 is T)
|
||||
return Attempt<T>.Succeed((T)value2);
|
||||
|
||||
// If ConvertDataToSource failed try ConvertSourceToObject.
|
||||
var value3 = converter.ConvertSourceToObject(properyType, value2, false);
|
||||
|
||||
// If the value is of type T, just return it
|
||||
if (value3 is T)
|
||||
return Attempt<T>.Succeed((T)value3);
|
||||
|
||||
// Value is not final value type, so try a regular type conversion aswell
|
||||
var convertAttempt = value2.TryConvertTo<T>();
|
||||
if (convertAttempt.Success)
|
||||
@@ -81,13 +107,14 @@ namespace Archetype.Models
|
||||
return Attempt<T>.Fail();
|
||||
}
|
||||
|
||||
private PublishedPropertyType CreateDummyPropertyType(int dataTypeId, string propertyEditorAlias)
|
||||
/// <summary>
|
||||
/// Model that represents the current UmbracoEditorState
|
||||
/// </summary>
|
||||
internal class UmbracoEditorState
|
||||
{
|
||||
return new PublishedPropertyType(this.HostContentType,
|
||||
new PropertyType(new DataTypeDefinition(-1, propertyEditorAlias)
|
||||
{
|
||||
Id = dataTypeId
|
||||
}));
|
||||
// container for the names of any files selected for a property in the Umbraco backend
|
||||
[JsonProperty("fileNames")]
|
||||
public IEnumerable<string> FileNames;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
|
||||
namespace Archetype.Models
|
||||
{
|
||||
public class ArchetypePublishedContent : IPublishedContent
|
||||
{
|
||||
private ArchetypeFieldsetModel _fieldset;
|
||||
|
||||
private IEnumerable<IPublishedContent> _parent;
|
||||
|
||||
private readonly Dictionary<string, IPublishedProperty> _properties;
|
||||
|
||||
public ArchetypePublishedContent(ArchetypeFieldsetModel fieldset, ArchetypePublishedContentSet parent = null)
|
||||
{
|
||||
if (fieldset == null)
|
||||
throw new ArgumentNullException("fieldset");
|
||||
|
||||
_fieldset = fieldset;
|
||||
_parent = parent ?? Enumerable.Empty<IPublishedContent>();
|
||||
|
||||
_properties = fieldset.Properties
|
||||
.ToDictionary(
|
||||
x => x.Alias,
|
||||
x => new ArchetypePublishedProperty(x) as IPublishedProperty,
|
||||
StringComparer.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
internal ArchetypeFieldsetModel ArchetypeFieldset
|
||||
{
|
||||
get { return _fieldset; }
|
||||
}
|
||||
|
||||
public IEnumerable<IPublishedContent> Children
|
||||
{
|
||||
get { return Enumerable.Empty<IPublishedContent>(); }
|
||||
}
|
||||
|
||||
public IEnumerable<IPublishedContent> ContentSet
|
||||
{
|
||||
get { return _parent; }
|
||||
}
|
||||
|
||||
public PublishedContentType ContentType
|
||||
{
|
||||
get { return default(PublishedContentType); }
|
||||
}
|
||||
|
||||
public DateTime CreateDate
|
||||
{
|
||||
get { return DateTime.MinValue; }
|
||||
}
|
||||
|
||||
public int CreatorId
|
||||
{
|
||||
get { return default(int); }
|
||||
}
|
||||
|
||||
public string CreatorName
|
||||
{
|
||||
get { return default(string); }
|
||||
}
|
||||
|
||||
public string DocumentTypeAlias
|
||||
{
|
||||
get { return _fieldset.Alias; }
|
||||
}
|
||||
|
||||
public int DocumentTypeId
|
||||
{
|
||||
get { return default(int); }
|
||||
}
|
||||
|
||||
public int GetIndex()
|
||||
{
|
||||
return _parent.IndexOf(this);
|
||||
}
|
||||
|
||||
public IPublishedProperty GetProperty(string alias, bool recurse)
|
||||
{
|
||||
IPublishedProperty property;
|
||||
return _properties.TryGetValue(alias, out property) ? property : null;
|
||||
}
|
||||
|
||||
public IPublishedProperty GetProperty(string alias)
|
||||
{
|
||||
return this.GetProperty(alias, false);
|
||||
}
|
||||
|
||||
public int Id
|
||||
{
|
||||
get { return default(int); }
|
||||
}
|
||||
|
||||
public bool IsDraft
|
||||
{
|
||||
get { return _fieldset.IsAvailable() == false; }
|
||||
}
|
||||
|
||||
public PublishedItemType ItemType
|
||||
{
|
||||
get { return PublishedItemType.Content; }
|
||||
}
|
||||
|
||||
public int Level
|
||||
{
|
||||
get { return default(int); }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return default(string); }
|
||||
}
|
||||
|
||||
public IPublishedContent Parent
|
||||
{
|
||||
get { return default(IPublishedContent); }
|
||||
}
|
||||
|
||||
public string Path
|
||||
{
|
||||
get { return default(string); }
|
||||
}
|
||||
|
||||
public ICollection<IPublishedProperty> Properties
|
||||
{
|
||||
get { return _properties.Values; }
|
||||
}
|
||||
|
||||
public int SortOrder
|
||||
{
|
||||
get { return default(int); }
|
||||
}
|
||||
|
||||
public int TemplateId
|
||||
{
|
||||
get { return default(int); }
|
||||
}
|
||||
|
||||
public DateTime UpdateDate
|
||||
{
|
||||
get { return default(DateTime); }
|
||||
}
|
||||
|
||||
public string Url
|
||||
{
|
||||
get { return default(string); }
|
||||
}
|
||||
|
||||
public string UrlName
|
||||
{
|
||||
get { return default(string); }
|
||||
}
|
||||
|
||||
public Guid Version
|
||||
{
|
||||
get { return Guid.Empty; }
|
||||
}
|
||||
|
||||
public int WriterId
|
||||
{
|
||||
get { return default(int); }
|
||||
}
|
||||
|
||||
public string WriterName
|
||||
{
|
||||
get { return default(string); }
|
||||
}
|
||||
|
||||
public object this[string alias]
|
||||
{
|
||||
get
|
||||
{
|
||||
var property = this.GetProperty(alias);
|
||||
|
||||
return property == null
|
||||
? null
|
||||
: property.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Archetype.Models
|
||||
{
|
||||
public class ArchetypePublishedContentSet : IEnumerable<ArchetypePublishedContent>
|
||||
{
|
||||
private IEnumerable<ArchetypePublishedContent> _items { get; set; }
|
||||
|
||||
public ArchetypePublishedContentSet(ArchetypeModel archetype)
|
||||
{
|
||||
if (archetype == null)
|
||||
throw new ArgumentNullException("archetype");
|
||||
|
||||
this.ArchetypeModel = archetype;
|
||||
|
||||
var count = archetype.Fieldsets.Count();
|
||||
|
||||
_items = archetype.Fieldsets
|
||||
.Where(x => x.IsAvailable())
|
||||
.Select(x => new ArchetypePublishedContent(x, this))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
internal ArchetypeModel ArchetypeModel { get; private set; }
|
||||
|
||||
public IEnumerator<ArchetypePublishedContent> GetEnumerator()
|
||||
{
|
||||
return _items.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return this.GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using Archetype.Extensions;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
|
||||
namespace Archetype.Models
|
||||
{
|
||||
public class ArchetypePublishedProperty : IPublishedProperty
|
||||
{
|
||||
private readonly object _rawValue;
|
||||
private readonly Lazy<object> _sourceValue;
|
||||
private readonly Lazy<object> _objectValue;
|
||||
private readonly Lazy<object> _xpathValue;
|
||||
private readonly ArchetypePropertyModel _property;
|
||||
private readonly PublishedPropertyType _propertyType;
|
||||
|
||||
public ArchetypePublishedProperty(ArchetypePropertyModel property)
|
||||
{
|
||||
if (property == null)
|
||||
throw new ArgumentNullException("property");
|
||||
|
||||
var preview = false;
|
||||
|
||||
_property = property;
|
||||
_rawValue = property.Value;
|
||||
|
||||
// #418 - need to wrap this in a try/catch to prevent orphaned properties from breaking everything
|
||||
try
|
||||
{
|
||||
_propertyType = property.CreateDummyPropertyType();
|
||||
|
||||
if (_propertyType != null)
|
||||
{
|
||||
_sourceValue = new Lazy<object>(() => _propertyType.ConvertDataToSource(_rawValue, preview));
|
||||
_objectValue = new Lazy<object>(() => _propertyType.ConvertSourceToObject(_sourceValue.Value, preview));
|
||||
_xpathValue = new Lazy<object>(() => _propertyType.ConvertSourceToXPath(_sourceValue.Value, preview));
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
LogHelper.Warn<ArchetypePublishedProperty>(string.Format("Could not create an IPublishedProperty for property: {0} - the error was: {1}", property.Alias, ex.Message));
|
||||
}
|
||||
}
|
||||
|
||||
internal ArchetypePropertyModel ArchetypeProperty
|
||||
{
|
||||
get { return _property; }
|
||||
}
|
||||
|
||||
public object DataValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return _sourceValue != null
|
||||
? _sourceValue.Value
|
||||
: _rawValue;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return _rawValue != null && !string.IsNullOrEmpty(_rawValue.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string PropertyTypeAlias
|
||||
{
|
||||
get { return _property.Alias; }
|
||||
}
|
||||
|
||||
public object Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return _objectValue != null
|
||||
? _objectValue.Value
|
||||
: _rawValue;
|
||||
}
|
||||
}
|
||||
|
||||
public object XPathValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return _xpathValue != null
|
||||
? _xpathValue.Value
|
||||
: _rawValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Archetype.Models
|
||||
{
|
||||
public class ArchetypeUpdateNotification
|
||||
{
|
||||
public bool IsUpdateAvailable { get; set; }
|
||||
public string Headline { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Message { get; set; }
|
||||
public string Url { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,9 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyTitle("Archetype")]
|
||||
[assembly: AssemblyDescription("Archetype's supporting code library for Umbraco")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Imulus")]
|
||||
[assembly: AssemblyCompany("Kevin Giszewski LLC")]
|
||||
[assembly: AssemblyProduct("Archetype")]
|
||||
[assembly: AssemblyCopyright("Copyright \xa9 Imulus 2014")]
|
||||
[assembly: AssemblyCopyright("MIT Licensed")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyVersion("1.3.0")]
|
||||
[assembly: AssemblyFileVersion("1.3.0-beta")]
|
||||
[assembly: AssemblyVersion("1.16.0")]
|
||||
[assembly: AssemblyFileVersion("1.16.0")]
|
||||
|
||||
@@ -8,22 +8,46 @@ using Umbraco.Core.Services;
|
||||
|
||||
namespace Archetype.PropertyConverters
|
||||
{
|
||||
/// <summary>
|
||||
/// Default property value converter that models the JSON to a C# object.
|
||||
/// </summary>
|
||||
[PropertyValueType(typeof(Models.ArchetypeModel))]
|
||||
[PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Content)]
|
||||
public class ArchetypeValueConverter : PropertyValueConverterBase
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Gets the services.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The services.
|
||||
/// </value>
|
||||
public ServiceContext Services
|
||||
{
|
||||
get { return ApplicationContext.Current.Services; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified property type is converter for Archetype.
|
||||
/// </summary>
|
||||
/// <param name="propertyType">Type of the property.</param>
|
||||
/// <returns></returns>
|
||||
public override bool IsConverter(PublishedPropertyType propertyType)
|
||||
{
|
||||
return !String.IsNullOrEmpty(propertyType.PropertyEditorAlias)
|
||||
var isArcheTypePropertyEditor = !String.IsNullOrEmpty(propertyType.PropertyEditorAlias)
|
||||
&& propertyType.PropertyEditorAlias.Equals(Constants.PropertyEditorAlias);
|
||||
if (!isArcheTypePropertyEditor)
|
||||
return false;
|
||||
|
||||
return !ArchetypeHelper.Instance.IsPropertyValueConverterOverridden(propertyType.DataTypeId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the data to source.
|
||||
/// </summary>
|
||||
/// <param name="propertyType">Type of the property.</param>
|
||||
/// <param name="source">The source.</param>
|
||||
/// <param name="preview">if set to <c>true</c> [preview].</param>
|
||||
/// <returns></returns>
|
||||
public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
|
||||
{
|
||||
var defaultValue = new ArchetypeModel();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Archetype.Extensions;
|
||||
using Archetype.Models;
|
||||
using ClientDependency.Core;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core;
|
||||
@@ -10,23 +12,34 @@ using Umbraco.Core.Models.Editors;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.PropertyEditors;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
|
||||
namespace Archetype.PropertyEditors
|
||||
{
|
||||
[PropertyEditorAsset(ClientDependencyType.Javascript, "/App_Plugins/Archetype/js/archetype.js")]
|
||||
[PropertyEditor("Imulus.Archetype", "Archetype", "/App_Plugins/Archetype/views/archetype.html", ValueType = "JSON")]
|
||||
/// <summary>
|
||||
/// C# representation of the property editor. This is often done with package manifest instead.
|
||||
/// </summary>
|
||||
[PropertyEditorAsset(ClientDependencyType.Javascript, "../App_Plugins/Archetype/js/archetype.js")]
|
||||
[PropertyEditor(Constants.PropertyEditorAlias, "Archetype", "../App_Plugins/Archetype/views/archetype.html", ValueType = "JSON")]
|
||||
public class ArchetypePropertyEditor : PropertyEditor
|
||||
{
|
||||
#region Pre Value Editor
|
||||
|
||||
/// <summary>
|
||||
/// Creates a pre value editor instance
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected override PreValueEditor CreatePreValueEditor()
|
||||
{
|
||||
return new ArchetypePreValueEditor();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class that represents the prevalue editor. This is often done with a package manifest instead.
|
||||
/// </summary>
|
||||
internal class ArchetypePreValueEditor : PreValueEditor
|
||||
{
|
||||
[PreValueField("archetypeConfig", "Config", "/App_Plugins/Archetype/views/archetype.config.html",
|
||||
[PreValueField("archetypeConfig", "Config", "../App_Plugins/Archetype/views/archetype.config.html",
|
||||
Description = "(Required) Describe your Archetype.")]
|
||||
public string Config { get; set; }
|
||||
|
||||
@@ -39,115 +52,227 @@ namespace Archetype.PropertyEditors
|
||||
|
||||
#region Value Editor
|
||||
|
||||
/// <summary>
|
||||
/// Creates a value editor instance
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected override PropertyValueEditor CreateValueEditor()
|
||||
{
|
||||
return new ArchetypePropertyValueEditor(base.CreateValueEditor());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class that represents the actual data editor. This is often done with a package manifest instead.
|
||||
/// </summary>
|
||||
internal class ArchetypePropertyValueEditor : PropertyValueEditorWrapper
|
||||
{
|
||||
protected JsonSerializerSettings _jsonSettings;
|
||||
|
||||
public ArchetypePropertyValueEditor(PropertyValueEditor wrapped)
|
||||
: base(wrapped) { }
|
||||
: base(wrapped)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the property value for use in the front-end cache
|
||||
/// </summary>
|
||||
/// <param name="property"></param>
|
||||
/// <param name="propertyType"></param>
|
||||
/// <param name="dataTypeService"></param>
|
||||
/// <returns></returns>
|
||||
public override string ConvertDbToString(Property property, PropertyType propertyType, IDataTypeService dataTypeService)
|
||||
{
|
||||
if (property.Value == null || property.Value.ToString() == "")
|
||||
if(property.Value == null || property.Value.ToString() == "")
|
||||
return string.Empty;
|
||||
|
||||
var archetype = ArchetypeHelper.Instance.DeserializeJsonToArchetype(property.Value.ToString(), propertyType.DataTypeDefinitionId);
|
||||
|
||||
foreach (var fieldset in archetype.Fieldsets)
|
||||
{
|
||||
foreach (var propDef in fieldset.Properties)
|
||||
foreach (var propDef in fieldset.Properties.Where(p => p.DataTypeGuid != null))
|
||||
{
|
||||
try
|
||||
{
|
||||
var dtd = dataTypeService.GetDataTypeDefinitionById(Guid.Parse(propDef.DataTypeGuid));
|
||||
var propType = new PropertyType(dtd) { Alias = propDef.Alias };
|
||||
var prop = new Property(propType, propDef.Value);
|
||||
var propEditor = PropertyEditorResolver.Current.GetByAlias(dtd.PropertyEditorAlias);
|
||||
propDef.Value = propEditor.ValueEditor.ConvertDbToString(prop, propType, dataTypeService);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<ArchetypeHelper>(ex.Message, ex);
|
||||
}
|
||||
try
|
||||
{
|
||||
if(propDef == null || propDef.DataTypeGuid == null) continue;
|
||||
var dtd = ArchetypeHelper.Instance.GetDataTypeByGuid(Guid.Parse(propDef.DataTypeGuid));
|
||||
var propType = new PropertyType(dtd) {Alias = propDef.Alias};
|
||||
var prop = new Property(propType, propDef.Value);
|
||||
var propEditor = PropertyEditorResolver.Current.GetByAlias(dtd.PropertyEditorAlias);
|
||||
propDef.Value = propEditor.ValueEditor.ConvertDbToString(prop, propType, dataTypeService);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<ArchetypePropertyValueEditor>(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return archetype.SerializeForPersistence();
|
||||
return archetype.SerializeForPersistence();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A method used to format the database value to a value that can be used by the editor
|
||||
/// </summary>
|
||||
/// <param name="property"></param>
|
||||
/// <param name="propertyType"></param>
|
||||
/// <param name="dataTypeService"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// The object returned will automatically be serialized into json notation. For most property editors
|
||||
/// the value returned is probably just a string but in some cases a json structure will be returned.
|
||||
/// </remarks>
|
||||
public override object ConvertDbToEditor(Property property, PropertyType propertyType, IDataTypeService dataTypeService)
|
||||
{
|
||||
if (property.Value == null || property.Value.ToString() == "")
|
||||
if(property.Value == null || property.Value.ToString() == "")
|
||||
return string.Empty;
|
||||
|
||||
var archetype = ArchetypeHelper.Instance.DeserializeJsonToArchetype(property.Value.ToString(), propertyType.DataTypeDefinitionId);
|
||||
|
||||
foreach (var fieldset in archetype.Fieldsets)
|
||||
{
|
||||
foreach (var propDef in fieldset.Properties)
|
||||
foreach (var propDef in fieldset.Properties.Where(p => p.DataTypeGuid != null))
|
||||
{
|
||||
try
|
||||
{
|
||||
var dtd = dataTypeService.GetDataTypeDefinitionById(Guid.Parse(propDef.DataTypeGuid));
|
||||
var propType = new PropertyType(dtd) { Alias = propDef.Alias };
|
||||
var prop = new Property(propType, propDef.Value);
|
||||
var propEditor = PropertyEditorResolver.Current.GetByAlias(dtd.PropertyEditorAlias);
|
||||
propDef.Value = propEditor.ValueEditor.ConvertDbToEditor(prop, propType, dataTypeService);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<ArchetypeHelper>(ex.Message, ex);
|
||||
}
|
||||
try
|
||||
{
|
||||
var dtd = ArchetypeHelper.Instance.GetDataTypeByGuid(Guid.Parse(propDef.DataTypeGuid));
|
||||
var propType = new PropertyType(dtd) {Alias = propDef.Alias};
|
||||
var prop = new Property(propType, propDef.Value);
|
||||
var propEditor = PropertyEditorResolver.Current.GetByAlias(dtd.PropertyEditorAlias);
|
||||
propDef.Value = propEditor.ValueEditor.ConvertDbToEditor(prop, propType, dataTypeService);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<ArchetypePropertyValueEditor>(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return archetype;
|
||||
}
|
||||
public override object ConvertEditorToDb(ContentPropertyData editorValue, object currentValue)
|
||||
|
||||
/// <summary>
|
||||
/// A method to deserialize the string value that has been saved in the content editor
|
||||
/// to an object to be stored in the database.
|
||||
/// </summary>
|
||||
/// <param name="editorValue"></param>
|
||||
/// <param name="currentValue">The current value that has been persisted to the database for this editor. This value may be usesful for
|
||||
/// how the value then get's deserialized again to be re-persisted. In most cases it will probably not be used.</param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// By default this will attempt to automatically convert the string value to the value type supplied by ValueType.
|
||||
/// If overridden then the object returned must match the type supplied in the ValueType, otherwise persisting the
|
||||
/// value to the DB will fail when it tries to validate the value type.
|
||||
/// </remarks>
|
||||
public override object ConvertEditorToDb(ContentPropertyData editorValue, object currentValue)
|
||||
{
|
||||
if (editorValue.Value == null || editorValue.Value.ToString() == "")
|
||||
if(editorValue.Value == null || editorValue.Value.ToString() == "")
|
||||
return string.Empty;
|
||||
|
||||
// attempt to deserialize the current property value as an Archetype
|
||||
var currentArchetype = currentValue != null ? ArchetypeHelper.Instance.DeserializeJsonToArchetype(currentValue.ToString(), editorValue.PreValues) : null;
|
||||
var archetype = ArchetypeHelper.Instance.DeserializeJsonToArchetype(editorValue.Value.ToString(), editorValue.PreValues);
|
||||
|
||||
// get all files uploaded via the file manager (if any)
|
||||
var uploadedFiles = editorValue.AdditionalData.ContainsKey("files") ? editorValue.AdditionalData["files"] as IEnumerable<ContentItemFile> : null;
|
||||
foreach (var fieldset in archetype.Fieldsets)
|
||||
{
|
||||
// make sure the publishing dates are in UTC
|
||||
fieldset.ReleaseDate = EnsureUtcDate(fieldset.ReleaseDate);
|
||||
fieldset.ExpireDate = EnsureUtcDate(fieldset.ExpireDate);
|
||||
|
||||
// assign an id to the fieldset if it has none (e.g. newly created fieldset)
|
||||
fieldset.Id = fieldset.Id == Guid.Empty ? Guid.NewGuid() : fieldset.Id;
|
||||
// find the corresponding fieldset in the current Archetype value (if any)
|
||||
var currentFieldset = currentArchetype != null ? currentArchetype.Fieldsets.FirstOrDefault(f => f.Id == fieldset.Id) : null;
|
||||
foreach (var propDef in fieldset.Properties)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dtd = ApplicationContext.Current.Services.DataTypeService.GetDataTypeDefinitionById(Guid.Parse(propDef.DataTypeGuid));
|
||||
var preValues = ApplicationContext.Current.Services.DataTypeService.GetPreValuesCollectionByDataTypeId(dtd.Id);
|
||||
var propData = new ContentPropertyData(propDef.Value, preValues, new Dictionary<string, object>());
|
||||
var propEditor = PropertyEditorResolver.Current.GetByAlias(dtd.PropertyEditorAlias);
|
||||
propDef.Value = propEditor.ValueEditor.ConvertEditorToDb(propData, propDef.Value);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<ArchetypeHelper>(ex.Message, ex);
|
||||
}
|
||||
try
|
||||
{
|
||||
// find the corresponding property in the current Archetype value (if any)
|
||||
var currentProperty = currentFieldset != null ? currentFieldset.Properties.FirstOrDefault(p => p.Alias == propDef.Alias) : null;
|
||||
var dtd = ArchetypeHelper.Instance.GetDataTypeByGuid(Guid.Parse(propDef.DataTypeGuid));
|
||||
var preValues = ApplicationContext.Current.Services.DataTypeService.GetPreValuesCollectionByDataTypeId(dtd.Id);
|
||||
|
||||
var additionalData = new Dictionary<string, object>();
|
||||
|
||||
// figure out if we need to pass a files collection in the additional data to the property value editor
|
||||
if(uploadedFiles != null)
|
||||
{
|
||||
if(dtd.PropertyEditorAlias == Constants.PropertyEditorAlias)
|
||||
{
|
||||
// it's a nested Archetype - just pass all uploaded files to the value editor
|
||||
additionalData["files"] = uploadedFiles.ToList();
|
||||
}
|
||||
else if (propDef.EditorState != null && propDef.EditorState.FileNames != null && propDef.EditorState.FileNames.Any())
|
||||
{
|
||||
// pass the uploaded files that belongs to this property (if any) to the value editor
|
||||
var propertyFiles = propDef.EditorState.FileNames.Select(fileName =>
|
||||
uploadedFiles.FirstOrDefault(u => u.FileName != null &&
|
||||
// #384, #389 and #394 - look for "safe" file names (using the ToSafeFileName() extension)
|
||||
// - for backwards compatibility we'll look for the raw filename as well as the "safe" file name
|
||||
(u.FileName.Equals(fileName, StringComparison.OrdinalIgnoreCase) || u.FileName.Equals(fileName.ToSafeFileName(), StringComparison.OrdinalIgnoreCase))
|
||||
)
|
||||
).Where(f => f != null).ToList();
|
||||
if(propertyFiles.Any())
|
||||
{
|
||||
additionalData["files"] = propertyFiles;
|
||||
}
|
||||
}
|
||||
}
|
||||
// #397 - pass along "cuid" and "puid" (part of the Umbraco 7.6 scheme)
|
||||
if(editorValue.AdditionalData.ContainsKey("cuid"))
|
||||
{
|
||||
additionalData["cuid"] = editorValue.AdditionalData["cuid"];
|
||||
}
|
||||
if(editorValue.AdditionalData.ContainsKey("puid"))
|
||||
{
|
||||
additionalData["puid"] = editorValue.AdditionalData["puid"];
|
||||
}
|
||||
var propData = new ContentPropertyData(propDef.Value, preValues, additionalData);
|
||||
var propEditor = PropertyEditorResolver.Current.GetByAlias(dtd.PropertyEditorAlias);
|
||||
// make sure to send the current property value (if any) to the PE ValueEditor
|
||||
propDef.Value = propEditor.ValueEditor.ConvertEditorToDb(propData, currentProperty != null ? currentProperty.Value : null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<ArchetypePropertyValueEditor>(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return archetype.SerializeForPersistence();
|
||||
}
|
||||
|
||||
internal virtual PropertyEditor GetPropertyEditor(IDataTypeDefinition dtd)
|
||||
{
|
||||
if (dtd.Id != 0)
|
||||
return PropertyEditorResolver.Current.GetByAlias(dtd.PropertyEditorAlias);
|
||||
|
||||
return dtd.PropertyEditorAlias.Equals(Constants.PropertyEditorAlias)
|
||||
? new ArchetypePropertyEditor()
|
||||
: (PropertyEditor)new TextboxPropertyEditor();
|
||||
}
|
||||
return archetype.SerializeForPersistence();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the property editor.
|
||||
/// </summary>
|
||||
/// <param name="dtd">The DTD.</param>
|
||||
/// <returns></returns>
|
||||
internal virtual PropertyEditor GetPropertyEditor(IDataTypeDefinition dtd)
|
||||
{
|
||||
if(dtd.Id != 0)
|
||||
return PropertyEditorResolver.Current.GetByAlias(dtd.PropertyEditorAlias);
|
||||
|
||||
return dtd.PropertyEditorAlias.Equals(Constants.PropertyEditorAlias)
|
||||
? new ArchetypePropertyEditor()
|
||||
: (PropertyEditor) new TextboxPropertyEditor();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures that a datetime is in UTC
|
||||
/// </summary>
|
||||
/// <param name="dateTime">The datetime</param>
|
||||
/// <returns>The datetime in UTC (or null if it's not set)</returns>
|
||||
private DateTime? EnsureUtcDate(DateTime? dateTime)
|
||||
{
|
||||
if(dateTime.HasValue == false || dateTime.Value.Kind == DateTimeKind.Utc)
|
||||
{
|
||||
return dateTime;
|
||||
}
|
||||
return new DateTime(dateTime.Value.Ticks, DateTimeKind.Utc);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,585 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Archetype.Models;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Archetype.Serialization
|
||||
{
|
||||
public class ArchetypeJsonConverter : JsonConverter
|
||||
{
|
||||
private const string _ROOT_FS_ALIAS = "rootFs";
|
||||
|
||||
#region public methods
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
var models = GenerateModels(value);
|
||||
|
||||
if (models.Count < 1)
|
||||
return;
|
||||
|
||||
if (models.Count == 1 && models[0] == null)
|
||||
return;
|
||||
|
||||
var jObj = SerializeModelToFieldset(models);
|
||||
|
||||
writer.WriteRaw(ApplyFormatting(jObj.ToString(), writer.Formatting));
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
var jToken = JToken.ReadFrom(reader);
|
||||
|
||||
if (jToken == null)
|
||||
return null;
|
||||
|
||||
return DeserializeJson(objectType, GetDelintedJToken(jToken));
|
||||
}
|
||||
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return IsTypeArchetypeDatatype(objectType);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region private methods - deserialization
|
||||
|
||||
private JToken GetDelintedJToken(JToken jToken)
|
||||
{
|
||||
return JToken.Parse(jToken.ToString(Formatting.None).DelintArchetypeJson());
|
||||
}
|
||||
|
||||
private object DeserializeJson(Type objectType, JToken jToken)
|
||||
{
|
||||
|
||||
var obj = Activator.CreateInstance(objectType);
|
||||
|
||||
if (null != obj as IEnumerable<object>)
|
||||
{
|
||||
JToken enumerableToken;
|
||||
|
||||
if (TryParseJTokenAsEnumerable(jToken, out enumerableToken)
|
||||
|| (jToken.SelectToken("value") != null && TryParseJTokenAsEnumerable(jToken["value"], out enumerableToken)))
|
||||
return DeserializeEnumerableObject(obj, enumerableToken);
|
||||
}
|
||||
|
||||
return null == jToken as JArray
|
||||
? DeserializeObject(obj, jToken)
|
||||
: PopulateProperties(obj, jToken);
|
||||
}
|
||||
|
||||
private object DeserializeEnumerableObject(object obj, JToken jToken)
|
||||
{
|
||||
var model = obj as IEnumerable<object>;
|
||||
var fsToken = jToken;
|
||||
|
||||
var itemType = model.GetType().GetGenericArguments().FirstOrDefault();
|
||||
|
||||
if (itemType == null)
|
||||
{
|
||||
itemType = model.GetType().BaseType.GetGenericArguments().First();
|
||||
fsToken = fsToken["fieldsets"];
|
||||
}
|
||||
|
||||
foreach (var fs in fsToken.Where(fs => fs["alias"].ToString().Equals(GetFieldsetName(itemType))))
|
||||
{
|
||||
var item = DeserializeJson(itemType, fs["properties"]);
|
||||
|
||||
obj.GetType().GetMethod("Add").Invoke(obj, new[] { item });
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
private object DeserializeObject(object obj, JToken jToken)
|
||||
{
|
||||
if (jToken.SelectToken("value") != null
|
||||
&& String.IsNullOrEmpty(jToken.SelectToken("value").ToString()))
|
||||
return obj;
|
||||
|
||||
var properties = GetSerialiazableProperties(obj).ToList();
|
||||
var asFieldset = properties.Where(HasAsFieldsetAttribute).ToList();
|
||||
|
||||
foreach (var propInfo in asFieldset)
|
||||
{
|
||||
var propAlias = GetJsonPropertyName(propInfo);
|
||||
var fsJToken = propInfo.PropertyType.Namespace.Equals("System")
|
||||
? GetFieldsetJTokenFromAlias(propAlias, jToken)
|
||||
: GetFieldsetJTokenFromPropertyAlias(propInfo, jToken);
|
||||
|
||||
var propJToken = GetPropertyJToken(fsJToken, propAlias);
|
||||
|
||||
if (propJToken == null)
|
||||
continue;
|
||||
|
||||
var propValue = GetPropertyValue(propInfo, propJToken);
|
||||
|
||||
propInfo.SetValue(obj, propValue);
|
||||
}
|
||||
|
||||
if (properties.All(HasAsFieldsetAttribute))
|
||||
return obj;
|
||||
|
||||
var objToken = GetFieldsetJTokenFromTypeAlias(obj.GetType(), jToken);
|
||||
|
||||
if (objToken == null)
|
||||
return obj;
|
||||
|
||||
if (objToken.SelectToken("properties") != null)
|
||||
return PopulateProperties(obj, objToken["properties"]);
|
||||
|
||||
if ((objToken is JArray) && (objToken as JArray).Count <= 0)
|
||||
return null;
|
||||
|
||||
if (!(objToken is JArray))
|
||||
return PopulateProperties(obj, new JArray(objToken));
|
||||
|
||||
var defaultFsProperties = properties.Where(pInfo => !HasAsFieldsetAttribute(pInfo)).ToList();
|
||||
|
||||
foreach (var property in defaultFsProperties)
|
||||
{
|
||||
var propJToken = ParseJTokenFromItems(objToken, GetJsonPropertyName(property));
|
||||
PopulateProperty(obj, propJToken["properties"], property);
|
||||
}
|
||||
|
||||
return PopulateProperties(obj, new JArray(objToken));
|
||||
}
|
||||
|
||||
private JToken GetPropertyJToken(JToken fsJToken, string propAlias)
|
||||
{
|
||||
if (fsJToken == null)
|
||||
return null;
|
||||
|
||||
//make recursive
|
||||
if (fsJToken.SelectToken("properties") != null)
|
||||
return GetPropertyAliasJToken(propAlias, fsJToken["properties"]);
|
||||
|
||||
var nestedPropJToken = fsJToken
|
||||
.SingleOrDefault(p => p.SelectToken("alias").ToString().Equals(propAlias));
|
||||
|
||||
return nestedPropJToken != null ? GetPropertyAliasJToken(propAlias, nestedPropJToken["properties"]) : null;
|
||||
}
|
||||
|
||||
private JToken GetFieldsetJTokenFromTypeAlias(Type objType, JToken jToken)
|
||||
{
|
||||
var objAlias = GetFieldsetName(objType);
|
||||
return GetFieldsetJTokenFromAlias(objAlias, jToken);
|
||||
}
|
||||
|
||||
private JToken GetFieldsetJTokenFromPropertyAlias(PropertyInfo propInfo, JToken jToken)
|
||||
{
|
||||
var objAlias = GetJsonPropertyName(propInfo);
|
||||
return GetFieldsetJTokenFromAlias(objAlias, jToken);
|
||||
}
|
||||
|
||||
private JToken GetFieldsetJTokenFromAlias(string objAlias, JToken jToken)
|
||||
{
|
||||
JToken propJToken;
|
||||
|
||||
if (TryParseJTokenFromNamedFieldset(jToken, objAlias, out propJToken))
|
||||
return propJToken;
|
||||
|
||||
if (TryParseJTokenFromNestedFieldset(jToken, objAlias, out propJToken))
|
||||
return propJToken;
|
||||
|
||||
if (TryParseJTokenFromDefaultFieldset(jToken, out propJToken))
|
||||
return propJToken;
|
||||
|
||||
return propJToken
|
||||
?? ParseJTokenFromItem(jToken, objAlias);
|
||||
}
|
||||
|
||||
private object PopulateProperties(object obj, JToken jToken)
|
||||
{
|
||||
var properties = GetSerialiazableProperties(obj);
|
||||
|
||||
foreach (var propertyInfo in properties)
|
||||
{
|
||||
PopulateProperty(obj, jToken, propertyInfo);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
private void PopulateProperty(object obj, JToken jToken, PropertyInfo propertyInfo)
|
||||
{
|
||||
var propAlias = GetJsonPropertyName(propertyInfo);
|
||||
var propJToken = GetPropertyAliasJToken(propAlias, jToken);
|
||||
|
||||
if (propJToken == null)
|
||||
return;
|
||||
|
||||
var propValue = GetPropertyValue(propertyInfo, propJToken);
|
||||
propertyInfo.SetValue(obj, propValue);
|
||||
}
|
||||
|
||||
private JToken GetPropertyAliasJToken(string propAlias, JToken jToken)
|
||||
{
|
||||
return jToken.SingleOrDefault(p => p.SelectToken("alias").ToString().Equals(propAlias));
|
||||
}
|
||||
|
||||
private object GetPropertyValue(PropertyInfo propertyInfo, JToken propJToken)
|
||||
{
|
||||
return IsTypeArchetypeDatatype(propertyInfo.PropertyType)
|
||||
? DeserializeJson(propertyInfo.PropertyType, propJToken)
|
||||
: IsTypeIEnumerableArchetypeDatatype(propertyInfo.PropertyType)
|
||||
? DeserializeJson(propertyInfo.PropertyType, propJToken["value"].SelectToken("fieldsets"))
|
||||
: GetDeserializedPropertyValue(propJToken, propertyInfo.PropertyType);
|
||||
}
|
||||
|
||||
private JToken ParseJTokenFromItem(JToken jToken, string itemAlias)
|
||||
{
|
||||
return (jToken.SelectToken("alias") != null && jToken["alias"].ToString().Equals(itemAlias))
|
||||
? jToken
|
||||
: null;
|
||||
}
|
||||
|
||||
private JToken ParseJTokenFromItems(JToken jToken, string itemAlias)
|
||||
{
|
||||
return jToken.SingleOrDefault(jT => ParseJTokenFromItem(jT, itemAlias) != null);
|
||||
}
|
||||
|
||||
private bool TryParseJTokenFromNamedFieldset(JToken jToken, string objAlias, out JToken resultToken)
|
||||
{
|
||||
resultToken = null;
|
||||
|
||||
if (jToken.SelectToken("fieldsets") == null)
|
||||
return false;
|
||||
|
||||
resultToken = jToken["fieldsets"].SingleOrDefault(p => p.SelectToken("alias").ToString().Equals(objAlias));
|
||||
|
||||
return resultToken != null;
|
||||
}
|
||||
|
||||
private bool TryParseJTokenFromNestedFieldset(JToken jToken, string objAlias, out JToken resultToken)
|
||||
{
|
||||
resultToken = null;
|
||||
|
||||
if (jToken.SelectToken("value") == null || !jToken["value"].HasValues
|
||||
|| jToken["value"]["fieldsets"] == null)
|
||||
return false;
|
||||
|
||||
resultToken = jToken["value"]["fieldsets"].SingleOrDefault(p => p.SelectToken("alias").ToString().Equals(objAlias));
|
||||
|
||||
return resultToken != null;
|
||||
}
|
||||
|
||||
private bool TryParseJTokenFromDefaultFieldset(JToken jToken, out JToken resultToken)
|
||||
{
|
||||
resultToken = jToken.SelectToken("fieldsets");
|
||||
|
||||
return resultToken != null;
|
||||
}
|
||||
|
||||
private bool TryParseJTokenAsEnumerable(JToken jToken, out JToken resultToken)
|
||||
{
|
||||
resultToken = null;
|
||||
|
||||
//To Do: Strange newtonsoft behaviour
|
||||
var fsToken = jToken.Parent != null
|
||||
? jToken.Parent.Children().First() is JArray
|
||||
? jToken.Parent.Children().First()
|
||||
: jToken.Parent.Children().First()["fieldsets"]
|
||||
: jToken.SelectToken("fieldsets");
|
||||
|
||||
var jTokenEnumerable = jToken != null
|
||||
&& fsToken != null && fsToken is JArray;
|
||||
|
||||
if (jTokenEnumerable)
|
||||
resultToken = jToken;
|
||||
|
||||
return jTokenEnumerable;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region private methods - serialization
|
||||
|
||||
private string ApplyFormatting(string json, Formatting formatting)
|
||||
{
|
||||
return JToken.Parse(json).ToString(formatting);
|
||||
}
|
||||
|
||||
private IList GenerateModels(object value)
|
||||
{
|
||||
var models = value as IList;
|
||||
|
||||
if (null != models)
|
||||
return models;
|
||||
|
||||
var properties = GetSerialiazableProperties(value).ToList();
|
||||
|
||||
if (!PropertyLayoutHasFieldsets(properties))
|
||||
return new List<object>() { value };
|
||||
|
||||
models = new List<object>();
|
||||
|
||||
var fieldsetModels = properties.Where(HasAsFieldsetAttribute)
|
||||
.Select(pInfo =>
|
||||
{
|
||||
var fsModel = GetDynamicModel(GetJsonPropertyName(pInfo));
|
||||
fsModel.Add(GetJsonPropertyName(pInfo), pInfo.GetValue(value));
|
||||
return fsModel;
|
||||
});
|
||||
|
||||
models = ((IEnumerable<object>)models).Concat(fieldsetModels).ToList();
|
||||
|
||||
var remainingProps = properties.Where(pInfo => !HasAsFieldsetAttribute(pInfo)).ToList();
|
||||
|
||||
if (!remainingProps.Any())
|
||||
return models;
|
||||
|
||||
var dynamicModel = GetDynamicModel(GetFieldsetName(value.GetType()));
|
||||
|
||||
foreach (var pInfo in properties.Where(pInfo => !HasAsFieldsetAttribute(pInfo)))
|
||||
{
|
||||
dynamicModel.Add(GetJsonPropertyName(pInfo), pInfo.GetValue(value));
|
||||
}
|
||||
|
||||
models.Add(dynamicModel);
|
||||
|
||||
return models;
|
||||
}
|
||||
|
||||
private IDictionary<string, object> GetDynamicModel(string rootFsAlias)
|
||||
{
|
||||
var dynamicModel = new ExpandoObject() as IDictionary<string, object>;
|
||||
dynamicModel.Add(_ROOT_FS_ALIAS, rootFsAlias);
|
||||
return dynamicModel;
|
||||
}
|
||||
|
||||
private JObject SerializeModelToFieldset(IEnumerable models)
|
||||
{
|
||||
var jObj = new JObject
|
||||
{
|
||||
{
|
||||
"fieldsets",
|
||||
new JArray(new JRaw(SerializeModels(models)))
|
||||
}
|
||||
};
|
||||
return jObj;
|
||||
}
|
||||
|
||||
private IEnumerable SerializeModels(IEnumerable models)
|
||||
{
|
||||
var fieldsetJson = (from object model in models where null != model select SerializeModel(model)).ToList();
|
||||
|
||||
return String.Join(",", fieldsetJson);
|
||||
}
|
||||
|
||||
private string SerializeModel(object value)
|
||||
{
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
var jObj = IsExpandoObject(value)
|
||||
? GetJObjectFromExpandoObject(value as IDictionary<string, object>)
|
||||
: GetJObject(value);
|
||||
|
||||
var fieldsetJson = new StringBuilder();
|
||||
var fieldsetWriter = new StringWriter(fieldsetJson);
|
||||
|
||||
using (var jsonWriter = new JsonTextWriter(fieldsetWriter))
|
||||
{
|
||||
jObj.WriteTo(jsonWriter);
|
||||
}
|
||||
|
||||
return fieldsetJson.ToString();
|
||||
}
|
||||
|
||||
private bool PropertyLayoutHasFieldsets(IEnumerable<PropertyInfo> properties)
|
||||
{
|
||||
return properties.Any(HasAsFieldsetAttribute);
|
||||
}
|
||||
|
||||
private static bool HasAsFieldsetAttribute(PropertyInfo pInfo)
|
||||
{
|
||||
return pInfo
|
||||
.GetCustomAttributes(typeof(AsFieldsetAttribute), true).Length > 0;
|
||||
}
|
||||
|
||||
private bool IsExpandoObject(object value)
|
||||
{
|
||||
return value.GetType().Name.Equals(typeof (ExpandoObject).Name);
|
||||
}
|
||||
|
||||
private JObject GetJObjectFromExpandoObject(IDictionary<string, object> expandoObj)
|
||||
{
|
||||
var jObj = new JObject
|
||||
{
|
||||
{
|
||||
"alias",
|
||||
new JValue(expandoObj[_ROOT_FS_ALIAS])
|
||||
}
|
||||
};
|
||||
|
||||
var fsProperties = new List<JObject>();
|
||||
|
||||
foreach (var item in expandoObj.SkipWhile(i => i.Key.Equals(_ROOT_FS_ALIAS)))
|
||||
{
|
||||
var property = item;
|
||||
var alias = property.Key;
|
||||
var value = property.Value;
|
||||
|
||||
fsProperties.Add(new JObject
|
||||
{
|
||||
new JProperty("alias", alias),
|
||||
new JProperty("value", value != null ? JToken.FromObject(value) : value)
|
||||
});
|
||||
}
|
||||
|
||||
jObj.Add("properties", new JRaw(JsonConvert.SerializeObject(fsProperties)));
|
||||
return jObj;
|
||||
}
|
||||
|
||||
private JObject GetJObject(object obj)
|
||||
{
|
||||
var jObj = new JObject
|
||||
{
|
||||
{
|
||||
"alias",
|
||||
new JValue(GetFieldsetName(obj.GetType()))
|
||||
}
|
||||
};
|
||||
|
||||
var properties = GetProperties(obj);
|
||||
|
||||
var fsProperties = new List<JObject>();
|
||||
|
||||
foreach (var propertyInfo in properties)
|
||||
{
|
||||
var fsProperty = new JObject();
|
||||
var jProperty = new JProperty("alias", GetJsonPropertyName(propertyInfo));
|
||||
fsProperty.Add(jProperty);
|
||||
|
||||
var propValue = propertyInfo.GetIndexParameters().Length == 0
|
||||
? propertyInfo.GetValue(obj, null)
|
||||
: obj as string;
|
||||
|
||||
fsProperty.Add(
|
||||
new JProperty("value", GetJPropertyValue(propValue)));
|
||||
|
||||
fsProperties.Add(fsProperty);
|
||||
}
|
||||
|
||||
jObj.Add("properties", new JRaw(JsonConvert.SerializeObject(fsProperties)));
|
||||
|
||||
return jObj;
|
||||
}
|
||||
|
||||
private object GetJPropertyValue(object value)
|
||||
{
|
||||
return IsValueArchetypeDatatype(value)
|
||||
? new JRaw(JsonConvert.SerializeObject(value))
|
||||
: IsValueIEnumerableArchetypeDatatype(value)
|
||||
? new JRaw(SerializeModelToFieldset(value as IEnumerable))
|
||||
: new JValue(GetSerializedPropertyValue(value));
|
||||
}
|
||||
|
||||
private IEnumerable<PropertyInfo> GetProperties(object obj)
|
||||
{
|
||||
if (obj.GetType() != typeof(string))
|
||||
return GetSerialiazableProperties(obj);
|
||||
|
||||
var indexer = ((DefaultMemberAttribute)obj.GetType()
|
||||
.GetCustomAttributes(typeof(DefaultMemberAttribute), true)[0]).MemberName;
|
||||
|
||||
return new List<PropertyInfo> { obj.GetType().GetProperty(indexer) };
|
||||
}
|
||||
|
||||
private IEnumerable<PropertyInfo> GetSerialiazableProperties(object obj)
|
||||
{
|
||||
return obj.GetSerialiazableProperties();
|
||||
}
|
||||
|
||||
private string GetJsonPropertyName(PropertyInfo property)
|
||||
{
|
||||
var attributes = property.GetCustomAttributes(true);
|
||||
var jsonPropAttribute = (JsonPropertyAttribute)attributes.FirstOrDefault(attr => attr is JsonPropertyAttribute);
|
||||
|
||||
return jsonPropAttribute != null ? jsonPropAttribute.PropertyName : property.Name;
|
||||
}
|
||||
|
||||
private string GetFieldsetName(Type type)
|
||||
{
|
||||
var attributes = type.GetCustomAttributes(true);
|
||||
var archetypeDatatypeAttribute = (AsArchetypeAttribute)attributes.FirstOrDefault(attr => attr is AsArchetypeAttribute);
|
||||
|
||||
return archetypeDatatypeAttribute != null ? archetypeDatatypeAttribute.FieldsetName : type.Name;
|
||||
}
|
||||
|
||||
private string GetSerializedPropertyValue(object propValue)
|
||||
{
|
||||
if (propValue == null)
|
||||
return String.Empty;
|
||||
|
||||
if (propValue is bool)
|
||||
return (bool)propValue ? GetSerializedPropertyValue(1) : GetSerializedPropertyValue(0);
|
||||
|
||||
return String.Format("{0}", propValue);
|
||||
}
|
||||
|
||||
private object GetDeserializedPropertyValue(JToken jToken, Type type)
|
||||
{
|
||||
return String.IsNullOrEmpty(jToken.ToString())
|
||||
? GetDefault(type)
|
||||
: GetTypedValue(jToken, type);
|
||||
}
|
||||
|
||||
private object GetTypedValue(JToken jToken, Type type)
|
||||
{
|
||||
var property = JsonConvert.DeserializeObject<ArchetypePropertyModel>(jToken.ToString());
|
||||
|
||||
var method = typeof(ArchetypePropertyModel).GetMethod("GetValue");
|
||||
var getValue = method.MakeGenericMethod(type);
|
||||
|
||||
return getValue.Invoke(property, null);
|
||||
}
|
||||
|
||||
private object GetDefault(Type type)
|
||||
{
|
||||
return type.IsValueType ? Activator.CreateInstance(type) : null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region private methods - common
|
||||
|
||||
private bool IsValueIEnumerableArchetypeDatatype(object value)
|
||||
{
|
||||
if (value as IEnumerable != null && value.GetType().IsGenericType)
|
||||
return IsTypeArchetypeDatatype(value.GetType().GetGenericArguments()[0]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool IsTypeIEnumerableArchetypeDatatype(Type type)
|
||||
{
|
||||
if (typeof(IEnumerable).IsAssignableFrom(type) && type.IsGenericType)
|
||||
return IsTypeArchetypeDatatype(type.GetGenericArguments()[0]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool IsValueArchetypeDatatype(object value)
|
||||
{
|
||||
return value != null &&
|
||||
IsTypeArchetypeDatatype(value.GetType());
|
||||
}
|
||||
|
||||
private bool IsTypeArchetypeDatatype(Type type)
|
||||
{
|
||||
return type.GetCustomAttributes(typeof(AsArchetypeAttribute), true).Length > 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Archetype.Serialization
|
||||
{
|
||||
public enum DelinterStep
|
||||
{
|
||||
RemoveNewLine = 0,
|
||||
RemoveWhiteSpace,
|
||||
UnescapeLabels,
|
||||
UnescapeAlias,
|
||||
UnescapeValues,
|
||||
FixNestedFieldsets
|
||||
}
|
||||
|
||||
public enum DelinterAction
|
||||
{
|
||||
Remove = 0,
|
||||
RemoveWhiteSpace,
|
||||
UnescapeLabels,
|
||||
UnescapeValues,
|
||||
FixNestedFieldsets
|
||||
}
|
||||
|
||||
public class ArchetypeJsonDelinter
|
||||
{
|
||||
public IDictionary<DelinterStep, DelinterAction> Pipeline { get; private set; }
|
||||
public IDictionary<DelinterStep, Regex> Tokens { get; private set; }
|
||||
public IDictionary<DelinterAction, Func<string, Regex, string>> Actions { get; private set; }
|
||||
|
||||
public ArchetypeJsonDelinter()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public string Execute(string input)
|
||||
{
|
||||
var buffer = input;
|
||||
|
||||
foreach (var step in Pipeline.Keys)
|
||||
{
|
||||
var action = Pipeline[step];
|
||||
buffer = Actions[action](buffer, Tokens[step]);
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
Tokens = new Dictionary<DelinterStep, Regex>
|
||||
{
|
||||
{DelinterStep.RemoveNewLine, new Regex(@"(?<=\,){0,1}(\\+r\\+n)(?=\\*?""(alias|value|properties|fieldsets)\\*?"":\{*?(\\*|""|\[))|(\r|\n)+|(\\+r\\+n)(?=\s*?(\{|\}|\]))|(\\+r\\n+)(?=\s+\\*?""(alias|value|properties|fieldsets))")},
|
||||
{DelinterStep.RemoveWhiteSpace, new Regex(@"(""\S+?"":)(\s+?)("")|([\{\[\}\],]|(?<!\\)"")(\s+)([\{\[\}\],]|(?<!\\)"")")},
|
||||
{DelinterStep.UnescapeLabels, new Regex(@"\\+""(fieldsets|properties|alias|value)\\+"":(\s*)")},
|
||||
{DelinterStep.UnescapeAlias, new Regex(@"""(alias)"":\\+""(.*?)\\+""")},
|
||||
{DelinterStep.UnescapeValues, new Regex(@"""(value)"":\\+""(.*?)\\+""(?=\s*?\})")},
|
||||
{DelinterStep.FixNestedFieldsets, new Regex(@"""(value)"":\s*?""\{\s*?(""fieldsets""[\S\s]+?)}""")}
|
||||
};
|
||||
|
||||
Actions = new Dictionary<DelinterAction, Func<string, Regex, string>>
|
||||
{
|
||||
{DelinterAction.Remove, (input, pattern) =>
|
||||
RecursiveReplace(input, pattern, match => String.Empty)
|
||||
},
|
||||
{DelinterAction.RemoveWhiteSpace, (input, pattern) =>
|
||||
RecursiveReplace(input.Trim(), pattern, match =>
|
||||
String.Format("{0}{1}{2}{3}", match.Groups[1].Value,
|
||||
match.Groups[3].Value, match.Groups[4].Value, match.Groups[6].Value))
|
||||
},
|
||||
{DelinterAction.UnescapeLabels, (input, pattern) =>
|
||||
RecursiveReplace(input, pattern, match => String.Format(@"""{0}"":", match.Groups[1].Value))
|
||||
},
|
||||
{DelinterAction.UnescapeValues, (input, pattern) =>
|
||||
RecursiveReplace(input, pattern, match => String.Format(@"""{0}"":""{1}""", match.Groups[1].Value, match.Groups[2].Value))
|
||||
},
|
||||
{DelinterAction.FixNestedFieldsets, (input, pattern) =>
|
||||
RecursiveReplace(input, pattern, match => String.Format(@"""{0}"":{{{1}}}", match.Groups[1].Value, match.Groups[2].Value))
|
||||
}
|
||||
};
|
||||
|
||||
Pipeline = new Dictionary<DelinterStep, DelinterAction>
|
||||
{
|
||||
{DelinterStep.RemoveNewLine, DelinterAction.Remove},
|
||||
{DelinterStep.UnescapeLabels, DelinterAction.UnescapeLabels},
|
||||
{DelinterStep.UnescapeAlias, DelinterAction.UnescapeValues},
|
||||
{DelinterStep.UnescapeValues, DelinterAction.UnescapeValues},
|
||||
{DelinterStep.FixNestedFieldsets, DelinterAction.FixNestedFieldsets},
|
||||
{DelinterStep.RemoveWhiteSpace, DelinterAction.RemoveWhiteSpace},
|
||||
};
|
||||
}
|
||||
|
||||
private string RecursiveReplace(string input, Regex pattern, Func<Match, string> matchFunc)
|
||||
{
|
||||
var buffer = input;
|
||||
while (pattern.IsMatch(buffer))
|
||||
{
|
||||
buffer = pattern.Replace(buffer, match => matchFunc(match));
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Archetype.Serialization
|
||||
{
|
||||
public class AsArchetypeAttribute : Attribute
|
||||
{
|
||||
public string FieldsetName { get; set; }
|
||||
|
||||
public AsArchetypeAttribute(string fieldsetname)
|
||||
{
|
||||
FieldsetName = fieldsetname;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Archetype.Serialization
|
||||
{
|
||||
public class AsFieldsetAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Reflection;
|
||||
using Archetype.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web;
|
||||
|
||||
namespace Archetype.Serialization
|
||||
{
|
||||
public static class SerializationExtensions
|
||||
{
|
||||
//temporary
|
||||
public static string GetPropertyDataValue(this IPublishedContent contentPage, string propertyAlias)
|
||||
{
|
||||
if (contentPage == null || !contentPage.HasProperty(propertyAlias))
|
||||
return null;
|
||||
|
||||
return (string)contentPage.Properties.Single(p => p.PropertyTypeAlias == propertyAlias).DataValue;
|
||||
}
|
||||
|
||||
public static IEnumerable<PropertyInfo> GetSerialiazableProperties(this object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return new List<PropertyInfo>();
|
||||
|
||||
return obj.GetType()
|
||||
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
|
||||
.Where(prop => !Attribute.IsDefined(prop, typeof(JsonIgnoreAttribute)));
|
||||
}
|
||||
|
||||
public static T GetModelFromArchetype<T>(this IPublishedContent content,
|
||||
string cmsFieldAlias, bool returnInstanceIfNull = false)
|
||||
where T : class, new()
|
||||
{
|
||||
var archetypeJson = content.GetPropertyDataValue(cmsFieldAlias);
|
||||
return JsonConvert.DeserializeObject<T>(archetypeJson) ??
|
||||
(returnInstanceIfNull ? Activator.CreateInstance<T>() : default(T));
|
||||
}
|
||||
|
||||
public static string DelintArchetypeJson(this string input)
|
||||
{
|
||||
if (!input.DetectIsJson())
|
||||
return String.Empty;
|
||||
|
||||
var delinter = new ArchetypeJsonDelinter();
|
||||
return delinter.Execute(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using Archetype.Extensions;
|
||||
using Archetype.Models;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Archetype.TypeConverters
|
||||
{
|
||||
public class ArchetypeFieldsetModelConverter : TypeConverter
|
||||
{
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(IPublishedContent) ||
|
||||
destinationType == typeof(ArchetypePublishedContent))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
// NOTE: The converter needs to return false here, otherwise `ArchetypeHelper.DeserializeJsonToArchetype` fails.
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (value is ArchetypeFieldsetModel && (destinationType == typeof(IPublishedContent) || destinationType == typeof(ArchetypePublishedContent)))
|
||||
{
|
||||
return ((ArchetypeFieldsetModel)value).ToPublishedContent();
|
||||
}
|
||||
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using Archetype.Extensions;
|
||||
using Archetype.Models;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Archetype.TypeConverters
|
||||
{
|
||||
public class ArchetypeModelConverter : TypeConverter
|
||||
{
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(ArchetypePublishedContentSet) ||
|
||||
destinationType == typeof(IEnumerable<IPublishedContent>))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (value is ArchetypeModel && (destinationType == typeof(ArchetypePublishedContentSet) || destinationType == typeof(IEnumerable<IPublishedContent>)))
|
||||
{
|
||||
return ((ArchetypeModel)value).ToPublishedContentSet();
|
||||
}
|
||||
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,33 @@
|
||||
angular.module("umbraco").controller("Imulus.ArchetypeConfigController", function ($scope, $http, assetsService, dialogService, archetypePropertyEditorResource) {
|
||||
angular.module("umbraco").controller("Imulus.ArchetypeConfigController", function ($scope, $http, assetsService, dialogService, archetypePropertyEditorResource, archetypeGlobalConfigService, notificationsService) {
|
||||
|
||||
//$scope.model.value = "";
|
||||
//console.log($scope.model.value);
|
||||
|
||||
//define empty items
|
||||
var newPropertyModel = '{"alias": "", "remove": false, "collapse": false, "label": "", "helpText": "", "dataTypeGuid": "0cc0eba1-9960-42c9-bf9b-60e150b429ae", "value": ""}';
|
||||
var newFieldsetModel = '{"alias": "", "remove": false, "collapse": false, "labelTemplate": "", "icon": "", "label": "", "properties": [' + newPropertyModel + ']}';
|
||||
var defaultFieldsetConfigModel = JSON.parse('{"showAdvancedOptions": false, "startWithAddButton": false, "hideFieldsetToolbar": false, "enableMultipleFieldsets": false, "hideFieldsetControls": false, "hidePropertyLabel": false, "maxFieldsets": null, "enableCollapsing": true, "enableDisabling": true, "fieldsets": [' + newFieldsetModel + ']}');
|
||||
var newFieldsetModel = '{"alias": "", "remove": false, "collapse": false, "labelTemplate": "", "icon": "", "label": "", "properties": [' + newPropertyModel + '], "group": null}';
|
||||
var defaultFieldsetConfigModel = JSON.parse('{"showAdvancedOptions": false, "startWithAddButton": false, "hideFieldsetToolbar": false, "enableMultipleFieldsets": false, "hideFieldsetControls": false, "hidePropertyLabel": false, "maxFieldsets": null, "enableCollapsing": true, "enableMultipleOpen": true, "enableCloning": false, "enableDisabling": true, "enableDeepDatatypeRequests": false, "enablePublishing": false, "enableMemberGroups": false, "enableCrossDragging": false, "fieldsets": [' + newFieldsetModel + '], "fieldsetGroups": []}');
|
||||
|
||||
//ini the model
|
||||
$scope.model.value = $scope.model.value || defaultFieldsetConfigModel;
|
||||
|
||||
$scope.dllVersion = "";
|
||||
|
||||
archetypePropertyEditorResource.getDllVersion().then(function(data){
|
||||
$scope.dllVersion = data.dllVersion;
|
||||
});
|
||||
|
||||
archetypeGlobalConfigService.checkForUpdates().then(function(data) {
|
||||
if(data.isUpdateAvailable) {
|
||||
notificationsService.add({
|
||||
headline: data.headline,
|
||||
type: data.type,
|
||||
message: data.message,
|
||||
url: data.url
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//ini the render model
|
||||
initConfigRenderModel();
|
||||
|
||||
@@ -41,6 +58,12 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio
|
||||
}
|
||||
};
|
||||
|
||||
// added to track loaded fieldsets
|
||||
$scope.loadedFieldsets = [];
|
||||
$scope.isLoaded = function (fieldset) {
|
||||
return $scope.loadedFieldsets.indexOf(fieldset) >= 0;
|
||||
}
|
||||
|
||||
//function that determines how to manage expanding/collapsing fieldsets
|
||||
$scope.focusFieldset = function(fieldset){
|
||||
var iniState;
|
||||
@@ -54,6 +77,7 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio
|
||||
if($scope.archetypeConfigRenderModel.fieldsets.length == 1 && fieldset.remove == false)
|
||||
{
|
||||
fieldset.collapse = false;
|
||||
$scope.loadedFieldsets.push(fieldset);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -64,12 +88,14 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio
|
||||
else
|
||||
{
|
||||
fieldset.collapse = false;
|
||||
$scope.loadedFieldsets.push(fieldset);
|
||||
}
|
||||
});
|
||||
|
||||
if(iniState)
|
||||
{
|
||||
fieldset.collapse = !iniState;
|
||||
$scope.loadedFieldsets.push(fieldset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +130,7 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio
|
||||
|
||||
//ini the properties
|
||||
_.each($scope.archetypeConfigRenderModel.fieldsets, function(fieldset){
|
||||
$scope.focusProperty(fieldset.properties);
|
||||
$scope.focusProperty(fieldset.properties);
|
||||
});
|
||||
|
||||
//setup JSON.stringify helpers
|
||||
@@ -117,27 +143,20 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio
|
||||
|
||||
//watch for changes
|
||||
$scope.$watch('archetypeConfigRenderModel', function (v) {
|
||||
//console.log(v);
|
||||
if (typeof v === 'string') {
|
||||
$scope.archetypeConfigRenderModel = JSON.parse(v);
|
||||
$scope.archetypeConfigRenderModel.toString = stringify;
|
||||
}
|
||||
});
|
||||
|
||||
$scope.autoPopulateAlias = function(s) {
|
||||
var modelType = s.hasOwnProperty('fieldset') ? 'fieldset' : 'property';
|
||||
var modelProperty = s[modelType];
|
||||
|
||||
if (!modelProperty.aliasIsDirty) {
|
||||
$scope.autoPopulateAlias = function (modelProperty) {
|
||||
if (modelProperty && !modelProperty.aliasIsDirty) {
|
||||
modelProperty.alias = modelProperty.label.toUmbracoAlias();
|
||||
}
|
||||
}
|
||||
|
||||
$scope.markAliasDirty = function(s) {
|
||||
var modelType = s.hasOwnProperty('fieldset') ? 'fieldset' : 'property';
|
||||
var modelProperty = s[modelType];
|
||||
|
||||
if (!modelProperty.aliasIsDirty) {
|
||||
$scope.markAliasDirty = function (modelProperty) {
|
||||
if (modelProperty && !modelProperty.aliasIsDirty) {
|
||||
modelProperty.aliasIsDirty = true;;
|
||||
}
|
||||
}
|
||||
@@ -238,8 +257,18 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio
|
||||
function initConfigRenderModel()
|
||||
{
|
||||
$scope.archetypeConfigRenderModel = $scope.model.value;
|
||||
if (!$scope.archetypeConfigRenderModel.fieldsetGroups) {
|
||||
$scope.archetypeConfigRenderModel.fieldsetGroups = [];
|
||||
}
|
||||
|
||||
_.each($scope.archetypeConfigRenderModel.fieldsets, function(fieldset){
|
||||
_.each($scope.archetypeConfigRenderModel.fieldsets, function(fieldset) {
|
||||
|
||||
if (fieldset.group) {
|
||||
// tie the fieldset group back up to the actual group object, not the clone that's been persisted
|
||||
fieldset.group = _.find($scope.archetypeConfigRenderModel.fieldsetGroups, function(fieldsetGroup) {
|
||||
return fieldsetGroup.name == fieldset.group.name;
|
||||
})
|
||||
}
|
||||
|
||||
fieldset.remove = false;
|
||||
if (fieldset.alias.length > 0)
|
||||
@@ -289,6 +318,24 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio
|
||||
$scope.model.value.fieldsets = fieldsets;
|
||||
}
|
||||
|
||||
$scope.showOptions = function ($event, template) {
|
||||
$event.preventDefault();
|
||||
|
||||
dialogService.closeAll();
|
||||
|
||||
dialogService.open({
|
||||
template: template,
|
||||
show: true,
|
||||
callback: function (data) {
|
||||
// replace the entire render model if it was changed (in developer options)
|
||||
if (data.model && data.modelChanged) {
|
||||
$scope.archetypeConfigRenderModel = data.model;
|
||||
}
|
||||
},
|
||||
dialogData: { model: $scope.archetypeConfigRenderModel }
|
||||
});
|
||||
}
|
||||
|
||||
//archetype css
|
||||
assetsService.loadCss("/App_Plugins/Archetype/css/archetype.css");
|
||||
assetsService.loadCss("../App_Plugins/Archetype/css/archetype.css");
|
||||
});
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
angular.module('umbraco').controller('ArchetypeConfigOptionsController', function ($scope) {
|
||||
|
||||
//handles a fieldset group add
|
||||
$scope.addFieldsetGroup = function () {
|
||||
$scope.dialogData.model.fieldsetGroups.push({ name: "" });
|
||||
}
|
||||
|
||||
//handles a fieldset group removal
|
||||
$scope.removeFieldsetGroup = function ($index) {
|
||||
$scope.dialogData.model.fieldsetGroups.splice($index, 1);
|
||||
}
|
||||
|
||||
$scope.apply = function(index) {
|
||||
$scope.submit($scope.dialogData);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
angular.module('umbraco').controller('ArchetypeConfigGlobalOptionsController', function ($scope, archetypeGlobalConfigService) {
|
||||
$scope.globalSettings = {};
|
||||
|
||||
$scope.confirmCheckNewVersionChange = function() {
|
||||
archetypeGlobalConfigService.setCheckForUpdates($scope.globalSettings.checkForNewVersion);
|
||||
}
|
||||
|
||||
function getGlobalSettings()
|
||||
{
|
||||
archetypeGlobalConfigService.globalSettings().then(function(data) {
|
||||
$scope.globalSettings.checkForNewVersion = data.isCheckingForUpdates;
|
||||
});
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
function init()
|
||||
{
|
||||
getGlobalSettings();
|
||||
}
|
||||
});
|
||||
+693
-66
@@ -1,4 +1,8 @@
|
||||
angular.module("umbraco").controller("Imulus.ArchetypeController", function ($scope, $http, assetsService, angularHelper, notificationsService, $timeout) {
|
||||
{{VERSION}}
|
||||
angular.module("umbraco").controller("Imulus.ArchetypeController", function ($scope, $http, $filter, $interpolate, assetsService, angularHelper, notificationsService, $timeout, fileManager, entityResource, archetypeService, archetypeLabelService, archetypeCacheService, archetypePropertyEditorResource, archetypeLocalizationService) {
|
||||
|
||||
// Variables.
|
||||
var draggedParent;
|
||||
|
||||
//$scope.model.value = "";
|
||||
$scope.model.hideLabel = $scope.model.config.hideLabel == 1;
|
||||
@@ -14,52 +18,312 @@
|
||||
|
||||
// store the umbraco property alias to help generate unique IDs. Hopefully there's a better way to get this in the future :)
|
||||
$scope.umbracoHostPropertyAlias = $scope.$parent.$parent.model.alias;
|
||||
|
||||
$scope.isDebuggingEnabled = Umbraco.Sys.ServerVariables.isDebuggingEnabled;
|
||||
|
||||
$scope.overlayMenu = {
|
||||
show: false,
|
||||
style: {}
|
||||
};
|
||||
|
||||
init();
|
||||
|
||||
//hold references to helper resources
|
||||
$scope.resources = {
|
||||
entityResource: entityResource,
|
||||
archetypePropertyEditorResource: archetypePropertyEditorResource
|
||||
}
|
||||
|
||||
//hold references to helper services
|
||||
$scope.services = {
|
||||
archetypeService: archetypeService,
|
||||
archetypeLabelService: archetypeLabelService,
|
||||
archetypeCacheService: archetypeCacheService
|
||||
}
|
||||
|
||||
//helper to get $eval the labelTemplate
|
||||
$scope.getFieldsetTitle = function(fieldsetConfigModel, fieldsetIndex) {
|
||||
if(!fieldsetConfigModel)
|
||||
return "";
|
||||
var fieldset = $scope.model.value.fieldsets[fieldsetIndex];
|
||||
var fieldsetConfig = $scope.getConfigFieldsetByAlias(fieldset.alias);
|
||||
var template = fieldsetConfigModel.labelTemplate;
|
||||
|
||||
if (template.length < 1)
|
||||
return fieldsetConfig.label;
|
||||
|
||||
var rgx = /{{(.*?)}}*/g;
|
||||
var results;
|
||||
var parsedTemplate = template;
|
||||
|
||||
while ((results = rgx.exec(template)) !== null) {
|
||||
var propertyAlias = results[1];
|
||||
var propertyValue = $scope.getPropertyValueByAlias(fieldset, propertyAlias);
|
||||
parsedTemplate = parsedTemplate.replace(results[0], propertyValue);
|
||||
}
|
||||
|
||||
return parsedTemplate;
|
||||
};
|
||||
$scope.getFieldsetTitle = function (fieldsetConfigModel, fieldsetIndex) {
|
||||
return archetypeLabelService.getFieldsetTitle($scope, fieldsetConfigModel, fieldsetIndex);
|
||||
}
|
||||
|
||||
//sort config
|
||||
$scope.sortableOptions = {
|
||||
axis: 'y',
|
||||
cursor: "move",
|
||||
handle: ".handle",
|
||||
tolerance: "pointer",
|
||||
activate: function(ev, ui) {
|
||||
|
||||
// Variables.
|
||||
var parentItem = ui.item.parent();
|
||||
var thisElement = parentItem[0];
|
||||
var targetElement = ev.target;
|
||||
var targetItem = angular.element(targetElement);
|
||||
|
||||
// The source of the drag can always be dropped back onto.
|
||||
if (targetElement === thisElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Variables.
|
||||
var sourceScope = ui.item.scope();
|
||||
var targetScope = targetItem.scope();
|
||||
var valid = canMove(sourceScope, targetScope);
|
||||
|
||||
// If the sortable can't be moved to the target Archetype, disable
|
||||
// the target Archetype's sortable temporarily.
|
||||
if (!valid) {
|
||||
var targetSortable = getSortableWidgetInstance(targetItem);
|
||||
targetSortable.disable();
|
||||
parentItem.sortable("refresh");
|
||||
archetypeService.rememberDisabledSortable(targetSortable);
|
||||
}
|
||||
|
||||
},
|
||||
start: function(ev, ui) {
|
||||
archetypeService.storeEditors(ui.item.parent());
|
||||
$scope.$apply(function() {
|
||||
draggedParent = ui.item.parent();
|
||||
draggedParent.scope().doingSort = true;
|
||||
});
|
||||
},
|
||||
update: function (ev, ui) {
|
||||
|
||||
// Variables.
|
||||
var targetScope = ui.item.sortable.droptarget.scope();
|
||||
var sourceScope = ui.item.scope();
|
||||
var sameScope = sourceScope === targetScope;
|
||||
var sourceIndex = ui.item.sortable.index;
|
||||
|
||||
// Special constraints for when moving between Archetypes.
|
||||
// If sourceScope is populated, we are in the first of the two updates (when
|
||||
// moving between lists, ui-sortable calls the update function twice).
|
||||
if (sourceScope && !sameScope) {
|
||||
|
||||
// Variables.
|
||||
var valid = canMove(sourceScope, targetScope);
|
||||
|
||||
// If update isn't allowed, cancel the drag operation.
|
||||
if (!valid) {
|
||||
ui.item.sortable.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear the validations for this item.
|
||||
clearValidations(ui.item.parent());
|
||||
clearValidations(ui.item.sortable.droptarget);
|
||||
|
||||
// Reset "isValid" on the properties and fieldsets.
|
||||
var fieldsetGroups = [
|
||||
$scope.model.value.fieldsets,
|
||||
targetScope.model.value.fieldsets
|
||||
];
|
||||
_.each(fieldsetGroups, function(fieldsets) {
|
||||
recurseProperties(function(property, fieldset) {
|
||||
property.isValid = true;
|
||||
fieldset.isValid = true;
|
||||
}, fieldsets);
|
||||
});
|
||||
|
||||
// Move the activated fieldset to the target Archetype.
|
||||
var movedFieldset = $scope.model.value.fieldsets[sourceIndex];
|
||||
var loadedIndex = $scope.loadedFieldsets.indexOf(movedFieldset);
|
||||
if (loadedIndex >= 0) {
|
||||
$scope.loadedFieldsets.splice(loadedIndex, 1);
|
||||
if (targetScope.loadedFieldsets.indexOf(movedFieldset) < 0) {
|
||||
targetScope.loadedFieldsets.push(movedFieldset);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Set scope dirty.
|
||||
$scope.setDirty();
|
||||
|
||||
},
|
||||
stop: function (ev, ui) {
|
||||
|
||||
// Done sorting.
|
||||
draggedParent.scope().doingSort = false;
|
||||
|
||||
// Enable disabled sortables.
|
||||
archetypeService.enableSortables();
|
||||
|
||||
// Restore rich text editors.
|
||||
var parent = null;
|
||||
var target = ui.item.sortable.droptarget;
|
||||
if (target) {
|
||||
parent = target.parent();
|
||||
}
|
||||
archetypeService.restoreEditors(parent);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// Clears the Angular validations in an Archetype.
|
||||
function clearValidations(el) {
|
||||
var combined = $(".archetypeSortable", el).add(el);
|
||||
combined.each(function(index, item) {
|
||||
var $item = angular.element(item);
|
||||
var cont = $item.controller("ngModel");
|
||||
var err = cont.$error;
|
||||
var keys = Object.keys(err);
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
cont.$setValidity(keys[i], true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Enable cross-archetype dragging?
|
||||
if ($scope.model.config.enableCrossDragging) {
|
||||
$scope.sortableOptions.connectWith = ".archetypeSortable:not(.invalid)";
|
||||
}
|
||||
|
||||
// Checks if the specified model's properties match all of the properties in any of
|
||||
// the specified fieldsets, while also checking if the fieldset aliases match.
|
||||
// This is an indicator of the compatibility of a fieldset model with a collection
|
||||
// of fieldset configurations.
|
||||
function modelMatchesAnyFieldset(model, fieldsets) {
|
||||
|
||||
// Loop through fieldsets to find a match.
|
||||
for (var i = 0; i < fieldsets.length; i++) {
|
||||
var fieldset = fieldsets[i];
|
||||
|
||||
// Confirm that this configured fielset contains exactly
|
||||
// the same properties as those that were supplied.
|
||||
var valid =
|
||||
// Does the alias match?
|
||||
model.alias === fieldset.alias &&
|
||||
// Does this fieldset have all the properties?
|
||||
arePropertiesSubset(model.properties, fieldset.properties) &&
|
||||
// Does the property array have all the fieldset properties?
|
||||
arePropertiesSubset(fieldset.properties, model.properties);
|
||||
|
||||
// Match found?
|
||||
if (valid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// No match found.
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
// Checks if the specified array of fieldsets contains the specified fieldset.
|
||||
function arrayContainsFieldset(fieldset, fieldsets) {
|
||||
for (var i = 0; i < fieldsets.length; i++) {
|
||||
if (fieldsets[i] === fieldset) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Confirms that an array of properties is a subset of another array of properties.
|
||||
function arePropertiesSubset(subset, superset) {
|
||||
|
||||
// Loop through the subset of properties.
|
||||
for (var j = 0; j < subset.length; j++) {
|
||||
var subProperty = subset[j];
|
||||
var matchedProp = false;
|
||||
|
||||
// Loop through the superset to find a matching property from the subset.
|
||||
for (var k = 0; k < superset.length; k++) {
|
||||
var superProperty = superset[k];
|
||||
if (superProperty.alias === subProperty.alias &&
|
||||
superProperty.dataTypeGuid === subProperty.dataTypeGuid) {
|
||||
matchedProp = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If no matching property could be found, the array is not a subset.
|
||||
if (!matchedProp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// The array is a subset.
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
//handles a fieldset add
|
||||
$scope.openFieldsetPicker = function ($index, event) {
|
||||
if ($scope.canAdd() == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
var allFieldsets = [];
|
||||
_.each($scope.model.config.fieldsets, function (fieldset) {
|
||||
var icon = fieldset.icon;
|
||||
allFieldsets.push({
|
||||
alias: fieldset.alias,
|
||||
label: fieldset.label,
|
||||
icon: (fieldset.icon || "icon-document-dashed-line"), // default icon if none is chosen
|
||||
group: fieldset.group ? fieldset.group.name : null,
|
||||
previewImage: fieldset.previewImage
|
||||
});
|
||||
});
|
||||
// sanity check
|
||||
if (allFieldsets == 0) {
|
||||
return;
|
||||
}
|
||||
if (allFieldsets.length == 1) {
|
||||
// only one fieldset type - no need to display the picker
|
||||
$scope.addRow(allFieldsets[0].alias, $index);
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.overlayMenu.fieldsetGroups = [];
|
||||
if ($scope.model.config.fieldsetGroups && $scope.model.config.fieldsetGroups.length > 0) {
|
||||
_.each($scope.model.config.fieldsetGroups, function (fieldsetGroup) {
|
||||
$scope.overlayMenu.fieldsetGroups.push({ name: fieldsetGroup.name, fieldsets: $filter("filter")(allFieldsets, { group: fieldsetGroup.name }, true) });
|
||||
})
|
||||
}
|
||||
else {
|
||||
$scope.overlayMenu.fieldsetGroups.push({ name: "", fieldsets: allFieldsets });
|
||||
}
|
||||
$scope.overlayMenu.index = $index;
|
||||
$scope.overlayMenu.activeFieldsetGroup = $scope.overlayMenu.fieldsetGroups[0];
|
||||
|
||||
// calculate overlay position
|
||||
// - yeah... it's jQuery (ungh!) but that's how the Grid does it.
|
||||
var offset = $(event.target).offset();
|
||||
var scrollTop = $(event.target).closest(".umb-panel-body").scrollTop();
|
||||
if (offset.top < 400) {
|
||||
$scope.overlayMenu.style.top = 300 + scrollTop;
|
||||
}
|
||||
else {
|
||||
$scope.overlayMenu.style.top = offset.top - 150 + scrollTop;
|
||||
}
|
||||
$scope.overlayMenu.show = true;
|
||||
};
|
||||
|
||||
$scope.closeFieldsetPicker = function () {
|
||||
$scope.overlayMenu.show = false;
|
||||
$scope.overlayMenu.fieldsetPreview = null;
|
||||
};
|
||||
|
||||
$scope.pickFieldset = function (fieldsetAlias, $index) {
|
||||
$scope.closeFieldsetPicker();
|
||||
$scope.addRow(fieldsetAlias, $index);
|
||||
};
|
||||
|
||||
$scope.openFieldsetPreview = function (fieldset) {
|
||||
$scope.overlayMenu.fieldsetPreview = fieldset;
|
||||
}
|
||||
|
||||
$scope.closeFieldsetPreview = function () {
|
||||
$scope.overlayMenu.fieldsetPreview = null;
|
||||
}
|
||||
|
||||
$scope.addRow = function (fieldsetAlias, $index) {
|
||||
if ($scope.canAdd())
|
||||
{
|
||||
if ($scope.model.config.fieldsets)
|
||||
{
|
||||
if ($scope.canAdd()) {
|
||||
if ($scope.model.config.fieldsets) {
|
||||
var newFieldset = getEmptyRenderFieldset($scope.getConfigFieldsetByAlias(fieldsetAlias));
|
||||
|
||||
if (typeof $index != 'undefined')
|
||||
@@ -71,10 +335,22 @@
|
||||
$scope.model.value.fieldsets.push(newFieldset);
|
||||
}
|
||||
}
|
||||
|
||||
addCustomPropertiesToFieldset(newFieldset);
|
||||
|
||||
$scope.setDirty();
|
||||
|
||||
$scope.$broadcast("archetypeAddFieldset", {index: $index, visible: countVisible()});
|
||||
|
||||
newFieldset.collapse = $scope.model.config.enableCollapsing ? true : false;
|
||||
|
||||
// If the fieldset is not collapsed, it should be instantly loaded.
|
||||
if (!newFieldset.collapse) {
|
||||
$scope.loadedFieldsets.push(newFieldset);
|
||||
}
|
||||
|
||||
$scope.focusFieldset(newFieldset);
|
||||
$scope.handleMandatoryValidation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +359,37 @@
|
||||
if (confirm('Are you sure you want to remove this?')) {
|
||||
$scope.setDirty();
|
||||
$scope.model.value.fieldsets.splice($index, 1);
|
||||
$scope.$broadcast("archetypeRemoveFieldset", {index: $index});
|
||||
$scope.handleMandatoryValidation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$scope.cloneRow = function ($index) {
|
||||
if ($scope.canClone() && typeof $index != 'undefined') {
|
||||
var newFieldset = angular.copy($scope.model.value.fieldsets[$index]);
|
||||
|
||||
if(newFieldset) {
|
||||
|
||||
// Regenerate the temporary ID on each nested fieldset.
|
||||
// This is done because no two fieldsets should have the same
|
||||
// temporary ID.
|
||||
recurseProperties(function(property) {
|
||||
archetypeService.ensureTemporaryId(property, true);
|
||||
}, [newFieldset]);
|
||||
|
||||
$scope.model.value.fieldsets.splice($index + 1, 0, newFieldset);
|
||||
|
||||
$scope.setDirty();
|
||||
|
||||
newFieldset.collapse = $scope.model.config.enableCollapsing ? true : false;
|
||||
|
||||
// If the fieldset is not collapsed, it should be instantly loaded.
|
||||
if (!newFieldset.collapse) {
|
||||
$scope.loadedFieldsets.push(newFieldset);
|
||||
}
|
||||
|
||||
$scope.focusFieldset(newFieldset);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,11 +398,34 @@
|
||||
fieldset.disabled = !fieldset.disabled;
|
||||
// explicitly set the form as dirty when manipulating the enabled/disabled state of a fieldset
|
||||
$scope.setDirty();
|
||||
$scope.handleMandatoryValidation();
|
||||
}
|
||||
|
||||
//helpers for determining if a user can do something
|
||||
$scope.canAdd = function ()
|
||||
{
|
||||
$scope.canAdd = function () {
|
||||
if ($scope.model.config.maxFieldsets)
|
||||
{
|
||||
var visibleCount = countVisible();
|
||||
var maxFieldsets = $scope.model.config.maxFieldsets;
|
||||
return visibleCount < maxFieldsets;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
//helper that returns if an item can be removed
|
||||
$scope.canRemove = function () {
|
||||
return countVisible() > 1
|
||||
|| ($scope.model.config.maxFieldsets == 1 && $scope.model.config.fieldsets.length > 1)
|
||||
|| $scope.model.config.startWithAddButton;
|
||||
};
|
||||
|
||||
$scope.canClone = function () {
|
||||
|
||||
if (!$scope.model.config.enableCloning) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($scope.model.config.maxFieldsets)
|
||||
{
|
||||
return countVisible() < $scope.model.config.maxFieldsets;
|
||||
@@ -104,19 +434,19 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
//helper that returns if an item can be removed
|
||||
$scope.canRemove = function ()
|
||||
{
|
||||
return countVisible() > 1
|
||||
|| ($scope.model.config.maxFieldsets == 1 && $scope.model.config.fieldsets.length > 1)
|
||||
|| $scope.model.config.startWithAddButton;
|
||||
}
|
||||
|
||||
//helper that returns if an item can be sorted
|
||||
$scope.canSort = function ()
|
||||
{
|
||||
return countVisible() > 1;
|
||||
}
|
||||
// Sorting can occur if there are multiple fieldsets, or if there is only one
|
||||
// fieldset that can be removed (in which case it can be sorted into an entirely
|
||||
// different Archetype).
|
||||
return countVisible() > 1 || $scope.canRemove();
|
||||
};
|
||||
|
||||
//helper that returns if an item is the last and it's being sorted.
|
||||
$scope.sortingLastItem = function() {
|
||||
return $scope.doingSort && $scope.model.value.fieldsets.length <= 1;
|
||||
};
|
||||
|
||||
//helper that returns if an item can be disabled
|
||||
$scope.canDisable = function () {
|
||||
@@ -130,10 +460,94 @@
|
||||
///&& $scope.model.config.fieldsets.length == 1;
|
||||
}
|
||||
|
||||
//helper that returns if an item can use publishing
|
||||
$scope.canPublish = function () {
|
||||
return $scope.model.config.enablePublishing;
|
||||
}
|
||||
|
||||
$scope.canUseMemberGroups = function() {
|
||||
return $scope.model.config.enableMemberGroups;
|
||||
}
|
||||
|
||||
//helper that returns if the "misc fieldset configuration" section should be visible
|
||||
$scope.canConfigure = function () {
|
||||
// currently the "misc fieldset configuration" section contains the publishing and the member groups setup
|
||||
return $scope.canPublish() || $scope.canUseMemberGroups();
|
||||
}
|
||||
|
||||
$scope.showDisableIcon = function (fieldset) {
|
||||
if ($scope.canDisable() == false) {
|
||||
return false;
|
||||
}
|
||||
// disabled state takes precedence over publishing
|
||||
if (fieldset.disabled) {
|
||||
return true;
|
||||
}
|
||||
return $scope.isDisabledByPublishing(fieldset) == false;
|
||||
}
|
||||
|
||||
$scope.showPublishingIcon = function (fieldset) {
|
||||
if ($scope.canPublish() == false) {
|
||||
return false;
|
||||
}
|
||||
if ($scope.canDisable()) {
|
||||
// disabled state takes precedence over publishing
|
||||
if (fieldset.disabled) {
|
||||
return false;
|
||||
}
|
||||
return $scope.isDisabledByPublishing(fieldset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
$scope.isDisabledByPublishing = function(fieldset) {
|
||||
if ($scope.canPublish() === false) {
|
||||
return false;
|
||||
}
|
||||
// NOTE: all comparison is done in local datetime
|
||||
// - that's fine because the selected local datetimes will be converted to UTC datetimes when submitted
|
||||
if (fieldset.expireDateModel && fieldset.expireDateModel.value && (moment() > moment(fieldset.expireDateModel.value))) {
|
||||
// an expired release affects the fieldset
|
||||
return true;
|
||||
}
|
||||
if (fieldset.releaseDateModel && fieldset.releaseDateModel.value && (moment(fieldset.releaseDateModel.value) > moment())) {
|
||||
// a pending release affects the fieldset
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
$scope.isDisabled = function(fieldset) {
|
||||
if (fieldset.disabled) {
|
||||
return true;
|
||||
}
|
||||
return $scope.isDisabledByPublishing(fieldset);
|
||||
}
|
||||
|
||||
$scope.numberOfEnabledFieldsets = function () {
|
||||
if (!$scope.model.value.fieldsets) {
|
||||
return 0;
|
||||
}
|
||||
return _.filter($scope.model.value.fieldsets, function (f) {
|
||||
return $scope.isDisabled(f) == false;
|
||||
}).length;
|
||||
}
|
||||
|
||||
//helper, ini the render model from the server (model.value)
|
||||
function init() {
|
||||
$scope.model.value = removeNulls($scope.model.value);
|
||||
addDefaultProperties($scope.model.value.fieldsets);
|
||||
|
||||
$timeout(function () {
|
||||
$scope.handleMandatoryValidation();
|
||||
}, 50);
|
||||
|
||||
// localize the message for minimum fieldsets validation errors
|
||||
archetypeLocalizationService.localize("minFieldsetsMessage").then(function (value) {
|
||||
value = value || "You must add minimum {{minFieldsets}} items";
|
||||
var exp = $interpolate(value);
|
||||
$scope.minFieldsetsMessage = exp({ minFieldsets: $scope.model.config.minFieldsets });
|
||||
});
|
||||
}
|
||||
|
||||
function addDefaultProperties(fieldsets)
|
||||
@@ -145,6 +559,36 @@
|
||||
});
|
||||
}
|
||||
|
||||
function addCustomProperties(fieldsets) {
|
||||
// make sure we have loaded moment.js before using it
|
||||
assetsService.loadJs("lib/moment/moment-with-locales.js").then(function() {
|
||||
_.each(fieldsets, function(fieldset) {
|
||||
addCustomPropertiesToFieldset(fieldset);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function addCustomPropertiesToFieldset(fieldset) {
|
||||
// create models for publish configuration (utilizing the built-in datepicker data type)
|
||||
// NOTE: all datetimes must be converted from UTC to local
|
||||
fieldset.releaseDateModel = {
|
||||
alias: _.uniqueId("archetypeReleaseDate_"),
|
||||
view: "datepicker",
|
||||
value: fromUtc(fieldset.releaseDate)
|
||||
};
|
||||
fieldset.expireDateModel = {
|
||||
alias: _.uniqueId("archetypeExpireDate_"),
|
||||
view: "datepicker",
|
||||
value: fromUtc(fieldset.expireDate)
|
||||
};
|
||||
// create model for allowed member groups
|
||||
fieldset.allowedMemberGroupsModel = {
|
||||
alias: _.uniqueId("archetypeAllowedMemberGroups_"),
|
||||
view: "membergrouppicker",
|
||||
value: fieldset.allowedMemberGroups
|
||||
};
|
||||
}
|
||||
|
||||
//helper to get the correct fieldset from config
|
||||
$scope.getConfigFieldsetByAlias = function(alias) {
|
||||
return _.find($scope.model.config.fieldsets, function(fieldset){
|
||||
@@ -164,9 +608,15 @@
|
||||
{
|
||||
if(typeof fieldset.collapse === "undefined")
|
||||
{
|
||||
fieldset.collapse = true;
|
||||
fieldset.collapse = $scope.model.config.enableCollapsing ? true : false;
|
||||
}
|
||||
return fieldset.collapse;
|
||||
};
|
||||
|
||||
// added to track loaded fieldsets
|
||||
$scope.loadedFieldsets = [];
|
||||
$scope.isLoaded = function (fieldset) {
|
||||
return $scope.loadedFieldsets.indexOf(fieldset) >= 0;
|
||||
}
|
||||
|
||||
//helper for expanding/collapsing fieldsets
|
||||
@@ -177,40 +627,76 @@
|
||||
return;
|
||||
}
|
||||
|
||||
var iniState;
|
||||
|
||||
if(fieldset)
|
||||
// collapse all other fieldsets if "multiple open fieldsets" is not enabled
|
||||
if(!$scope.model.config.enableMultipleOpen)
|
||||
{
|
||||
iniState = fieldset.collapse;
|
||||
_.each($scope.model.value.fieldsets, function (f) {
|
||||
if(f != fieldset)
|
||||
{
|
||||
f.collapse = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_.each($scope.model.value.fieldsets, function(fieldset){
|
||||
fieldset.collapse = true;
|
||||
});
|
||||
|
||||
if(!fieldset && $scope.model.value.fieldsets.length == 1)
|
||||
{
|
||||
$scope.model.value.fieldsets[0].collapse = false;
|
||||
$scope.loadedFieldsets.push($scope.model.value.fieldsets[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
if(iniState && fieldset)
|
||||
if(fieldset)
|
||||
{
|
||||
fieldset.collapse = !iniState;
|
||||
fieldset.collapse = !fieldset.collapse;
|
||||
if($scope.loadedFieldsets.indexOf(fieldset) < 0)
|
||||
{
|
||||
$scope.loadedFieldsets.push(fieldset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//ini the fieldset expand/collapse
|
||||
$scope.focusFieldset();
|
||||
|
||||
// Fieldsets which cannot be collapsed should start expanded.
|
||||
_.each($scope.model.value.fieldsets, function(fieldset) {
|
||||
fieldset.collapse = $scope.model.config.enableCollapsing;
|
||||
});
|
||||
$scope.loadedFieldsets = _.where($scope.model.value.fieldsets, { collapse: false });
|
||||
|
||||
//developerMode helpers
|
||||
$scope.model.value.toString = stringify;
|
||||
|
||||
// issue 114: register handler for file selection
|
||||
$scope.model.value.setFiles = setFiles;
|
||||
|
||||
//encapsulate stringify (should be built into browsers, not sure of IE support)
|
||||
function stringify() {
|
||||
return JSON.stringify(this);
|
||||
}
|
||||
|
||||
// issue 114: handler for file selection
|
||||
function setFiles(files) {
|
||||
// get all currently selected files from file manager
|
||||
var currentFiles = fileManager.getFiles();
|
||||
|
||||
// get the files already selected for this archetype (by alias)
|
||||
var archetypeFiles = [];
|
||||
_.each(currentFiles, function (item) {
|
||||
if (item.alias === $scope.model.alias) {
|
||||
archetypeFiles.push(item.file);
|
||||
}
|
||||
});
|
||||
|
||||
// add the newly selected files
|
||||
_.each(files, function (file) {
|
||||
archetypeFiles.push(file);
|
||||
});
|
||||
|
||||
// update the selected files for this archetype (by alias)
|
||||
fileManager.setFiles($scope.model.alias, archetypeFiles);
|
||||
}
|
||||
|
||||
//watch for changes
|
||||
$scope.$watch('model.value', function (v) {
|
||||
if ($scope.model.config.developerMode) {
|
||||
@@ -220,6 +706,22 @@
|
||||
$scope.model.value.toString = stringify;
|
||||
}
|
||||
}
|
||||
|
||||
// issue 114: re-register handler for files selection and reset the currently selected files on the file manager
|
||||
$scope.model.value.setFiles = setFiles;
|
||||
fileManager.setFiles($scope.model.alias, []);
|
||||
|
||||
// reset submit watcher counter on save
|
||||
$scope.activeSubmitWatcher = 0;
|
||||
|
||||
// init loaded fieldsets tracking
|
||||
_.each($scope.model.value.fieldsets, function (fieldset) {
|
||||
fieldset.collapse = $scope.model.config.enableCollapsing ? true : false;
|
||||
});
|
||||
$scope.loadedFieldsets = _.where($scope.model.value.fieldsets, { collapse: false });
|
||||
|
||||
// create properties needed for the backoffice to work (data that is not serialized to DB)
|
||||
addCustomProperties($scope.model.value.fieldsets);
|
||||
});
|
||||
|
||||
//helper to count what is visible
|
||||
@@ -280,24 +782,21 @@
|
||||
|
||||
//helper to lookup validity when given a fieldset
|
||||
$scope.getFieldsetValidity = function (fieldset) {
|
||||
if (fieldset.isValid == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// recursive validation of nested fieldsets
|
||||
var nestedFieldsetsValid = true;
|
||||
_.each(fieldset.properties, function (property) {
|
||||
if (property != null && property.value != null && property.propertyEditorAlias == "Imulus.Archetype") {
|
||||
_.each(property.value.fieldsets, function (inner) {
|
||||
if ($scope.getFieldsetValidity(inner) == false) {
|
||||
nestedFieldsetsValid = false;
|
||||
}
|
||||
});
|
||||
// Variables.
|
||||
var valid = true;
|
||||
|
||||
// Recursive validation of nested fieldsets.
|
||||
recurseFieldsets(function(item) {
|
||||
if (item.isValid === false) {
|
||||
valid = false;
|
||||
}
|
||||
});
|
||||
}, [fieldset]);
|
||||
|
||||
return nestedFieldsetsValid;
|
||||
}
|
||||
// Were all the nested fieldsets valid?
|
||||
return valid;
|
||||
|
||||
};
|
||||
|
||||
// helper to force the current form into the dirty state
|
||||
$scope.setDirty = function () {
|
||||
@@ -306,17 +805,145 @@
|
||||
}
|
||||
}
|
||||
|
||||
$scope.minFieldsetsFulfilled = function () {
|
||||
if (!$scope.model.config.minFieldsets) {
|
||||
return true;
|
||||
}
|
||||
return $scope.numberOfEnabledFieldsets() >= $scope.model.config.minFieldsets;
|
||||
}
|
||||
|
||||
//custom js
|
||||
if ($scope.model.config.customJsPath) {
|
||||
assetsService.loadJs($scope.model.config.customJsPath);
|
||||
}
|
||||
|
||||
//archetype css
|
||||
assetsService.loadCss("/App_Plugins/Archetype/css/archetype.css");
|
||||
assetsService.loadCss("../App_Plugins/Archetype/css/archetype.css");
|
||||
|
||||
//custom css
|
||||
if($scope.model.config.customCssPath)
|
||||
{
|
||||
assetsService.loadCss($scope.model.config.customCssPath);
|
||||
}
|
||||
|
||||
// submit watcher handling:
|
||||
// because some property editors use the "formSubmitting" event to set/clean up their model.value,
|
||||
// we need to monitor the "formSubmitting" event from a custom property and broadcast our own event
|
||||
// to forcefully update the appropriate model.value's
|
||||
$scope.activeSubmitWatcher = 0;
|
||||
$scope.submitWatcherOnLoad = function () {
|
||||
$scope.activeSubmitWatcher++;
|
||||
return $scope.activeSubmitWatcher;
|
||||
}
|
||||
$scope.submitWatcherOnSubmit = function (args) {
|
||||
$scope.$broadcast("archetypeFormSubmitting", args);
|
||||
}
|
||||
|
||||
// we'll use our own "archetypeFormSubmitting" event to save custom properties, as at least some
|
||||
// of the editors store their values back to the model on the core "formSubmitting" event
|
||||
$scope.$on("archetypeFormSubmitting", function (ev, args) {
|
||||
_.each($scope.model.value.fieldsets, function (fieldset) {
|
||||
// extract the publish configuration from the fieldsets (and convert local datetimes to UTC)
|
||||
fieldset.releaseDate = toUtc(fieldset.releaseDateModel.value);
|
||||
fieldset.expireDate = toUtc(fieldset.expireDateModel.value);
|
||||
// extract the allowed member groups
|
||||
fieldset.allowedMemberGroups = fieldset.allowedMemberGroupsModel.value;
|
||||
});
|
||||
});
|
||||
|
||||
// handle mandatory validation of the entire Archetype
|
||||
// - no fieldsets = not valid
|
||||
$scope.handleMandatoryValidation = function() {
|
||||
var valid = true;
|
||||
if ($scope.model.validation && $scope.model.validation.mandatory) {
|
||||
valid = $scope.numberOfEnabledFieldsets() > 0;
|
||||
}
|
||||
$scope.model.mandatoryValidation = valid ? "valid" : null;
|
||||
}
|
||||
|
||||
function toUtc(date) {
|
||||
if (!date) {
|
||||
return null;
|
||||
}
|
||||
return moment(date, "YYYY-MM-DD HH:mm:ss").utc().toDate();
|
||||
}
|
||||
|
||||
function fromUtc(date) {
|
||||
if (!date) {
|
||||
return null;
|
||||
}
|
||||
return moment(moment.utc(date).toDate()).format("YYYY-MM-DD HH:mm:ss")
|
||||
}
|
||||
|
||||
// Serializes and deserializes an item to return a snapshot of that item (e.g., so it is not
|
||||
// changed before being inspected). Useful when troubleshooting.
|
||||
// Modified from: http://stackoverflow.com/a/11616993/2052963
|
||||
function jsonSnapshot(item) {
|
||||
var cache = [];
|
||||
var stringItem = JSON.stringify(item, function(key, value) {
|
||||
if (typeof value === "object" && value !== null) {
|
||||
if (cache.indexOf(value) !== -1) {
|
||||
return "[Removed Circular Reference Item]";
|
||||
}
|
||||
cache.push(value);
|
||||
}
|
||||
return value;
|
||||
});
|
||||
return JSON.parse(stringItem);
|
||||
}
|
||||
|
||||
// Recursively processes each Archetype fieldset.
|
||||
function recurseFieldsets(fn, fieldsets) {
|
||||
if (!fieldsets || !fieldsets.length) {
|
||||
return;
|
||||
}
|
||||
_.each(fieldsets, function(fieldset) {
|
||||
fn(fieldset);
|
||||
_.each(fieldset.properties, function (property) {
|
||||
if (property != null && property.value != null && property.propertyEditorAlias === "Imulus.Archetype") {
|
||||
recurseFieldsets(fn, property.value.fieldsets);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Recursively processes each Archetype fieldset property.
|
||||
function recurseProperties(fn, fieldsets) {
|
||||
recurseFieldsets(function(fieldset) {
|
||||
_.each(fieldset.properties, function (property) {
|
||||
fn(property, fieldset);
|
||||
});
|
||||
}, fieldsets);
|
||||
}
|
||||
|
||||
// Indicates whether or not the fieldset can be moved between the source and target scope.
|
||||
// The source scope is the scope of the fieldset being dragged.
|
||||
// The target scope is the scope of the Archetype to drop into.
|
||||
function canMove(sourceScope, targetScope) {
|
||||
var targetFieldsetConfigs = targetScope.model.config.fieldsets;
|
||||
var targetFieldsets = targetScope.model.value.fieldsets;
|
||||
var sourceFieldset = sourceScope.fieldset;
|
||||
var sameArchetype = arrayContainsFieldset(sourceFieldset, targetFieldsets);
|
||||
var model = sourceScope.fieldsetConfigModel;
|
||||
var canRemove = sourceScope.canRemove();
|
||||
var canAdd = targetScope.canAdd();
|
||||
var valid = sameArchetype || (canRemove && canAdd);
|
||||
valid = valid && modelMatchesAnyFieldset(model, targetFieldsetConfigs);
|
||||
return valid;
|
||||
}
|
||||
|
||||
// This is an alternative to: element.sortable("instance")
|
||||
// Workaround for this issue: https://github.com/imulus/Archetype/pull/356#issuecomment-218527910
|
||||
// Snagged from this pull request: https://github.com/angular-ui/ui-sortable/pull/319
|
||||
// More technical details here: https://github.com/angular-ui/ui-sortable/issues/316
|
||||
function getSortableWidgetInstance(element) {
|
||||
// this is a fix to support jquery-ui prior to v1.11.x
|
||||
// otherwise we should be using `element.sortable('instance')`
|
||||
var data = element.data('ui-sortable');
|
||||
if (data && typeof data === 'object' && data.widgetFullName === 'ui-sortable') {
|
||||
return data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ angular.module("umbraco.directives").directive('archetypeLocalize', function (ar
|
||||
|
||||
return {
|
||||
restrict: "E",
|
||||
rep1ace: true,
|
||||
replace: true,
|
||||
link: linker,
|
||||
scope: {
|
||||
key: '@'
|
||||
@@ -0,0 +1,29 @@
|
||||
angular.module("umbraco.directives")
|
||||
.directive('archetypeClickOutside', function ($timeout, $parse) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function (scope, element, attrs, ctrl) {
|
||||
var fn = $parse(attrs.archetypeClickOutside);
|
||||
|
||||
// add click event handler (delayed so we don't trigger the callback immediately if this directive itself was triggered by a mouse click)
|
||||
$timeout(function () {
|
||||
$(document).on("click", mouseClick);
|
||||
}, 500);
|
||||
|
||||
function mouseClick(event) {
|
||||
if($(event.target).closest(element).length > 0) {
|
||||
return;
|
||||
}
|
||||
var callback = function () {
|
||||
fn(scope, { $event: event });
|
||||
};
|
||||
scope.$apply(callback);
|
||||
}
|
||||
|
||||
// unbind event
|
||||
scope.$on('$destroy', function () {
|
||||
$(document).off("click", mouseClick);
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -1,12 +1,12 @@
|
||||
angular.module("umbraco.directives").directive('archetypeCustomView', function ($compile, $http) {
|
||||
var linker = function (scope, element, attrs) {
|
||||
|
||||
var view = "/App_plugins/Archetype/views/archetype.default.html";
|
||||
var view = "../App_plugins/Archetype/views/archetype.default.html";
|
||||
if(scope.model.config.customViewPath) {
|
||||
view = config.customViewPath;
|
||||
view = scope.model.config.customViewPath;
|
||||
}
|
||||
|
||||
$http.get(view).then(function(data) {
|
||||
$http.get(view, { cache: true }).then(function(data) {
|
||||
|
||||
element.html(data.data).show();
|
||||
|
||||
|
||||
+113
-155
@@ -1,79 +1,33 @@
|
||||
angular.module("umbraco.directives").directive('archetypeProperty', function ($compile, $http, archetypePropertyEditorResource, umbPropEditorHelper, $timeout, $rootScope, $q) {
|
||||
|
||||
function getFieldsetByAlias(fieldsets, alias)
|
||||
{
|
||||
return _.find(fieldsets, function(fieldset){
|
||||
return fieldset.alias == alias;
|
||||
});
|
||||
}
|
||||
|
||||
function getPropertyIndexByAlias(properties, alias){
|
||||
for (var i in properties)
|
||||
{
|
||||
if (properties[i].alias == alias) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getPropertyByAlias(fieldset, alias){
|
||||
return _.find(fieldset.properties, function(property){
|
||||
return property.alias == alias;
|
||||
});
|
||||
}
|
||||
|
||||
//helper that returns a JS ojbect from 'value' string or the original string
|
||||
function jsonOrString(value, developerMode, debugLabel){
|
||||
if(value && typeof value == 'string'){
|
||||
try{
|
||||
if(developerMode == '1'){
|
||||
console.log("Trying to parse " + debugLabel + ": " + value);
|
||||
}
|
||||
value = JSON.parse(value);
|
||||
}
|
||||
catch(exception)
|
||||
{
|
||||
if(developerMode == '1'){
|
||||
console.log("Failed to parse " + debugLabel + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(value && developerMode == '1'){
|
||||
console.log(debugLabel + " post-parsing: ");
|
||||
console.log(value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
angular.module("umbraco.directives").directive('archetypeProperty', function ($compile, $http, archetypePropertyEditorResource, umbPropEditorHelper, $timeout, $rootScope, $q, fileManager, editorState, archetypeService, archetypeCacheService) {
|
||||
|
||||
var linker = function (scope, element, attrs, ngModelCtrl) {
|
||||
var configFieldsetModel = getFieldsetByAlias(scope.archetypeConfig.fieldsets, scope.fieldset.alias);
|
||||
var configFieldsetModel = archetypeService.getFieldsetByAlias(scope.archetypeConfig.fieldsets, scope.fieldset.alias);
|
||||
var view = "";
|
||||
var label = configFieldsetModel.properties[scope.propertyConfigIndex].label;
|
||||
var dataTypeGuid = configFieldsetModel.properties[scope.propertyConfigIndex].dataTypeGuid;
|
||||
var config = null;
|
||||
var alias = configFieldsetModel.properties[scope.propertyConfigIndex].alias;
|
||||
var defaultValue = configFieldsetModel.properties[scope.propertyConfigIndex].value;
|
||||
var propertyAlias = getUniquePropertyAlias(scope);
|
||||
propertyAliasParts = [];
|
||||
// initialize container for invalid fieldset property identifiers (store on ngModelCtrl to separate Archetype validations, e.g. when there two Archetype properties on the same document)
|
||||
if(ngModelCtrl.invalidProperties == null) {
|
||||
ngModelCtrl.invalidProperties = [];
|
||||
}
|
||||
|
||||
var propertyAliasParts = [];
|
||||
var propertyAlias = archetypeService.getUniquePropertyAlias(scope, propertyAliasParts);
|
||||
|
||||
//try to convert the defaultValue to a JS object
|
||||
defaultValue = jsonOrString(defaultValue, scope.archetypeConfig.developerMode, "defaultValue");
|
||||
defaultValue = archetypeService.jsonOrString(defaultValue, scope.archetypeConfig.developerMode, "defaultValue");
|
||||
|
||||
//grab info for the selected datatype, prepare for view
|
||||
archetypePropertyEditorResource.getDataType(dataTypeGuid).then(function (data) {
|
||||
archetypePropertyEditorResource.getDataType(dataTypeGuid, scope.archetypeConfig.enableDeepDatatypeRequests, editorState.current.contentTypeAlias, scope.propertyEditorAlias, alias, editorState.current.id).then(function (data) {
|
||||
//transform preValues array into object expected by propertyeditor views
|
||||
var configObj = {};
|
||||
|
||||
_.each(data.preValues, function(p) {
|
||||
configObj[p.key] = p.value;
|
||||
});
|
||||
|
||||
config = configObj;
|
||||
|
||||
//caching for use by label templates later
|
||||
archetypeCacheService.addDatatypeToCache(data, dataTypeGuid);
|
||||
|
||||
//determine the view to use [...] and load it
|
||||
archetypePropertyEditorResource.getPropertyEditorMapping(data.selectedEditor).then(function(propertyEditor) {
|
||||
var pathToView = umbPropEditorHelper.getViewPath(propertyEditor.view);
|
||||
@@ -86,100 +40,15 @@ angular.module("umbraco.directives").directive('archetypeProperty', function ($c
|
||||
|
||||
var mergedConfig = _.extend(defaultConfigObj, config);
|
||||
|
||||
loadView(pathToView, mergedConfig, defaultValue, alias, propertyAlias, scope, element, ngModelCtrl, validateProperty);
|
||||
loadView(pathToView, mergedConfig, defaultValue, alias, propertyAlias, scope, element, ngModelCtrl, configFieldsetModel);
|
||||
});
|
||||
});
|
||||
|
||||
scope.$on("formSubmitting", function (ev, args) {
|
||||
// "hard" validate to highlight any erroneous entries
|
||||
_.each(scope.fieldset.properties, function (property) {
|
||||
validateProperty(scope.fieldset, property, true);
|
||||
});
|
||||
});
|
||||
|
||||
scope.$on("formSubmitted", function (ev, args) {
|
||||
// reset the nested fieldset validation state after submit
|
||||
ngModelCtrl.invalidProperties = [];
|
||||
});
|
||||
|
||||
// need to pass the property fieldset here to clear any invalid state of the fieldset when validating a single fieldset property
|
||||
// - it's the Umbraco way to hide the invalid state when altering an invalid property, even if the new value isn't valid either
|
||||
function validateProperty(fieldset, property, markAsInvalid) {
|
||||
var valid = true;
|
||||
fieldset.isValid = true;
|
||||
property.isValid = true;
|
||||
var propertyConfig = getPropertyByAlias(configFieldsetModel, property.alias);
|
||||
if (propertyConfig) {
|
||||
// use property.value !== property.value to check for NaN values on numeric inputs
|
||||
if (propertyConfig.required && (property.value == null || property.value === "" || property.value !== property.value)) {
|
||||
valid = false;
|
||||
}
|
||||
// issue 116: RegEx validate property value
|
||||
// Only validate the property value if anything has been entered - RegEx is considered a supplement to "required".
|
||||
if (valid == true && propertyConfig.regEx && property.value) {
|
||||
var regEx = new RegExp(propertyConfig.regEx);
|
||||
if (regEx.test(property.value) == false) {
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
// only mark the property as invalid when doing a "hard" validation
|
||||
if (valid == false && markAsInvalid == true) {
|
||||
property.isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
// handle nested fieldset validation by storing the identifier of all invalid fieldset properties
|
||||
var fieldsetIdentifier = scope.umbracoPropertyAlias + "_" + scope.fieldsetIndex;
|
||||
var propertyIdentifier = fieldsetIdentifier + "_" + property.alias;
|
||||
var propertyIdentifierIndex = ngModelCtrl.invalidProperties.indexOf(propertyIdentifier);
|
||||
if (valid == false) {
|
||||
if (propertyIdentifierIndex == -1) {
|
||||
ngModelCtrl.invalidProperties.push(propertyIdentifier);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (propertyIdentifierIndex != -1) {
|
||||
ngModelCtrl.invalidProperties.splice(propertyIdentifierIndex, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (markAsInvalid) {
|
||||
// mark the entire fieldset as invalid if there are any invalid properties in the fieldset, otherwise mark it as valid
|
||||
fieldset.isValid =
|
||||
_.find(ngModelCtrl.invalidProperties, function (item) {
|
||||
return item.indexOf(fieldsetIdentifier) == 0
|
||||
}) == null;
|
||||
}
|
||||
|
||||
// set invalid state if one or more fieldsets contain invalid properties
|
||||
ngModelCtrl.$setValidity('validation', ngModelCtrl.invalidProperties.length == 0);
|
||||
}
|
||||
}
|
||||
|
||||
var propertyAliasParts = [];
|
||||
var getUniquePropertyAlias = function (currentScope) {
|
||||
if (currentScope.hasOwnProperty('fieldsetIndex') && currentScope.hasOwnProperty('property') && currentScope.hasOwnProperty('propertyConfigIndex'))
|
||||
{
|
||||
var currentPropertyAlias = "f" + currentScope.fieldsetIndex + "-" + currentScope.property.alias + "-p" + currentScope.propertyConfigIndex;
|
||||
propertyAliasParts.push(currentPropertyAlias);
|
||||
}
|
||||
else if (currentScope.hasOwnProperty('isPreValue')) // Crappy way to identify this is the umbraco property scope
|
||||
{
|
||||
var umbracoPropertyAlias = currentScope.$parent.$parent.property.alias; // Crappy way to get the umbraco host alias once we identify its scope
|
||||
propertyAliasParts.push(umbracoPropertyAlias);
|
||||
}
|
||||
|
||||
if (currentScope.$parent)
|
||||
getUniquePropertyAlias(currentScope.$parent);
|
||||
|
||||
return _.unique(propertyAliasParts).reverse().join("-");
|
||||
};
|
||||
|
||||
|
||||
function loadView(view, config, defaultValue, alias, propertyAlias, scope, element, ngModelCtrl, validateProperty) {
|
||||
function loadView(view, config, defaultValue, alias, propertyAlias, scope, element, ngModelCtrl, configFieldsetModel) {
|
||||
if (view)
|
||||
{
|
||||
$http.get(view).success(function (data) {
|
||||
$http.get(view, { cache: true }).success(function (data) {
|
||||
if (data) {
|
||||
if (scope.archetypeConfig.developerMode == '1')
|
||||
{
|
||||
@@ -192,28 +61,116 @@ angular.module("umbraco.directives").directive('archetypeProperty', function ($c
|
||||
scope.model.config = {};
|
||||
|
||||
//ini the property value after test to make sure a prop exists in the renderModel
|
||||
var renderModelPropertyIndex = getPropertyIndexByAlias(scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties, alias);
|
||||
scope.renderModelPropertyIndex = archetypeService.getPropertyIndexByAlias(archetypeService.getFieldset(scope).properties, alias);
|
||||
|
||||
if (!renderModelPropertyIndex)
|
||||
if (!scope.renderModelPropertyIndex)
|
||||
{
|
||||
scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties.push(JSON.parse('{"alias": "' + alias + '", "value": "' + defaultValue + '"}'));
|
||||
renderModelPropertyIndex = getPropertyIndexByAlias(scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties, alias);
|
||||
var propertyValue = { alias: alias, value: defaultValue };
|
||||
archetypeService.getFieldset(scope).properties.push(propertyValue);
|
||||
scope.renderModelPropertyIndex = archetypeService.getPropertyIndexByAlias(archetypeService.getFieldset(scope).properties, alias);
|
||||
}
|
||||
|
||||
scope.renderModel = {};
|
||||
scope.model.value = archetypeService.getFieldsetProperty(scope).value;
|
||||
|
||||
// init the property editor state (while ensuring the temporary ID is retained
|
||||
// from any prior initializations).
|
||||
var fieldsetProperty = archetypeService.getFieldsetProperty(scope);
|
||||
var oldState = fieldsetProperty.editorState;
|
||||
archetypeService.ensureTemporaryId(fieldsetProperty);
|
||||
if (oldState) {
|
||||
fieldsetProperty.editorState.temporaryId = oldState.temporaryId;
|
||||
}
|
||||
scope.model.value = scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties[renderModelPropertyIndex].value;
|
||||
|
||||
//set the config from the prevalues
|
||||
scope.model.config = config;
|
||||
|
||||
/*
|
||||
Property Specific Hacks
|
||||
|
||||
Preference is to not do these, but unless we figure out core issues, this is quickest fix.
|
||||
*/
|
||||
|
||||
//MNTP *single* hack
|
||||
if(scope.model.config.maxNumber && scope.model.config.multiPicker)
|
||||
{
|
||||
if(scope.model.config.maxNumber == "1")
|
||||
{
|
||||
scope.model.config.multiPicker = "0";
|
||||
}
|
||||
}
|
||||
|
||||
//hacks for various built-in datatyps including upload, colorpicker and tags
|
||||
if (!scope.propertyForm) {
|
||||
scope.propertyForm = scope.form;
|
||||
}
|
||||
if (!scope.model.validation) {
|
||||
scope.model.validation = {};
|
||||
scope.model.validation.mandatory = 0;
|
||||
}
|
||||
|
||||
//some items need an alias
|
||||
scope.model.alias = "archetype-property-" + propertyAlias;
|
||||
//some items also need an id (file upload for example)
|
||||
scope.model.id = propertyAlias;
|
||||
|
||||
//watch for changes since there is no two-way binding with the local model.value
|
||||
scope.$watch('model.value', function (newValue, oldValue) {
|
||||
scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties[renderModelPropertyIndex].value = newValue;
|
||||
|
||||
archetypeService.getFieldsetProperty(scope).value = newValue;
|
||||
|
||||
// call validation method for the property when the value changes
|
||||
// use "soft" validation to mimic the default umbraco validation style (show error highlights on submit, not while entering data)
|
||||
validateProperty(scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex], scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties[renderModelPropertyIndex], false);
|
||||
// notify the linker that the property value changed
|
||||
archetypeService.propertyValueChanged(archetypeService.getFieldset(scope), archetypeService.getFieldsetProperty(scope));
|
||||
});
|
||||
|
||||
scope.$on('archetypeFormSubmitting', function (ev, args) {
|
||||
// #385 - revert the changes made in #311 to avoid publishing invalid fieldsets (leaving the code from #311 here, in case we figure out how to re-introduce "save as draft")
|
||||
// if(args.action !== 'save') {
|
||||
// validate all fieldset properties
|
||||
_.each(scope.fieldset.properties, function (property) {
|
||||
archetypeService.validateProperty(scope.fieldset, property, configFieldsetModel);
|
||||
});
|
||||
|
||||
var validationKey = "validation-f" + scope.fieldsetIndex;
|
||||
|
||||
ngModelCtrl.$setValidity(validationKey, scope.fieldset.isValid);
|
||||
// }
|
||||
|
||||
// did the value change (if it did, it most likely did so during the "formSubmitting" event)
|
||||
var property = archetypeService.getFieldsetProperty(scope);
|
||||
|
||||
var currentValue = property.value;
|
||||
|
||||
if (currentValue != scope.model.value) {
|
||||
archetypeService.getFieldsetProperty(scope).value = scope.model.value;
|
||||
|
||||
// notify the linker that the property value changed
|
||||
archetypeService.propertyValueChanged(archetypeService.getFieldset(scope), archetypeService.getFieldsetProperty(scope));
|
||||
}
|
||||
});
|
||||
|
||||
// issue 114: handle file selection on property editors
|
||||
scope.$on("filesSelected", function (event, args) {
|
||||
// populate the fileNames collection on the property editor state
|
||||
var property = archetypeService.getFieldsetProperty(scope);
|
||||
|
||||
property.editorState.fileNames = [];
|
||||
|
||||
_.each(args.files, function (item) {
|
||||
property.editorState.fileNames.push(item.name);
|
||||
});
|
||||
|
||||
// remove the files set for this property
|
||||
// NOTE: we can't use property.alias because the file manager registers the selected files on the assigned Archetype property alias (e.g. "archetype-property-archetype-property-archetype-property-content-0-2-0-1-0-0")
|
||||
fileManager.setFiles(scope.model.alias, []);
|
||||
|
||||
// now tell the containing Archetype to pick up the selected files
|
||||
scope.archetypeRenderModel.setFiles(args.files);
|
||||
});
|
||||
|
||||
scope.$on("archetypeRemoveFieldset", function (ev, args) {
|
||||
var validationKey = "validation-f" + args.index;
|
||||
ngModelCtrl.$setValidity(validationKey, true);
|
||||
});
|
||||
|
||||
element.html(data).show();
|
||||
@@ -237,6 +194,7 @@ angular.module("umbraco.directives").directive('archetypeProperty', function ($c
|
||||
scope: {
|
||||
property: '=',
|
||||
propertyConfigIndex: '=',
|
||||
propertyEditorAlias: '=',
|
||||
archetypeConfig: '=',
|
||||
fieldset: '=',
|
||||
fieldsetIndex: '=',
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
angular.module("umbraco.directives").directive('archetypeSubmitWatcher', function ($rootScope) {
|
||||
var linker = function (scope, element, attrs, ngModelCtrl) {
|
||||
// call the load callback on scope to obtain the ID of this submit watcher
|
||||
var id = scope.loadCallback ? scope.loadCallback() : 0;
|
||||
|
||||
scope.$on("formSubmitting", function (ev, args) {
|
||||
// on the "formSubmitting" event, call the submit callback on scope to notify the Archetype controller to do it's magic
|
||||
if (id == scope.activeSubmitWatcher) {
|
||||
scope.submitCallback(args);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
restrict: "E",
|
||||
replace: true,
|
||||
link: linker,
|
||||
template: "",
|
||||
scope: {
|
||||
loadCallback: '=',
|
||||
submitCallback: '=',
|
||||
activeSubmitWatcher: '='
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
var ArchetypeSampleLabelTemplates = (function() {
|
||||
|
||||
//public functions
|
||||
return {
|
||||
Entity: function (value, scope, args) {
|
||||
|
||||
if(!args.entityType) {
|
||||
args = {entityType: "Document", propertyName: "name"}
|
||||
}
|
||||
|
||||
if (value) {
|
||||
//if handed a csv list, take the first only
|
||||
var id = value.split(",")[0];
|
||||
|
||||
if (id) {
|
||||
var entity = scope.services.archetypeCacheService.getEntityById(scope, id, args.entityType);
|
||||
|
||||
if(entity) {
|
||||
return entity[args.propertyName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
},
|
||||
UrlPicker: function(value, scope, args) {
|
||||
|
||||
if(!args.propertyName) {
|
||||
args = {propertyName: "name"}
|
||||
}
|
||||
|
||||
var entity;
|
||||
|
||||
switch (value.type) {
|
||||
case "content":
|
||||
if(value.typeData.contentId) {
|
||||
entity = scope.services.archetypeCacheService.getEntityById(scope, value.typeData.contentId, "Document");
|
||||
}
|
||||
break;
|
||||
|
||||
case "media":
|
||||
if(value.typeData.mediaId) {
|
||||
entity = scope.services.archetypeCacheService.getEntityById(scope, value.typeData.mediaId, "Media");
|
||||
}
|
||||
break;
|
||||
|
||||
case "url":
|
||||
return value.typeData.url;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if(entity) {
|
||||
return entity[args.propertyName];
|
||||
}
|
||||
|
||||
return "";
|
||||
},
|
||||
Rte: function (value, scope, args) {
|
||||
|
||||
if(!args.contentLength) {
|
||||
args = {contentLength: 50}
|
||||
}
|
||||
|
||||
return $(value).text().substring(0, args.contentLength);
|
||||
}
|
||||
}
|
||||
})();
|
||||
+26
-1
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"label": "Label",
|
||||
"alias": "Alias",
|
||||
"addFieldset": "Tilføj et element",
|
||||
"hideFieldsetControls": "Skjul fieldsets?",
|
||||
"hideFieldsetControlsDescription": "Skjuler kontrollerne tilføj/fjern/sortér.",
|
||||
"toggleAdvanced": "Slå avancerede muligheder til/fra",
|
||||
@@ -33,5 +34,29 @@
|
||||
"select": "Vælg",
|
||||
"icon": "Ikon",
|
||||
"enableDisabling": "Aktivér fieldset-deaktivering?",
|
||||
"enableDisablingDescription": "Tillad brugere at aktivere/deaktivere individuelle fieldsets."
|
||||
"enableDisablingDescription": "Tillad brugere at aktivere/deaktivere individuelle fieldsets.",
|
||||
"deepDatatypeRequest":"Enable Deep Datatype Requests?",
|
||||
"deepDatatypeRequestDescription":"Allows for easier datatype interception at the cost of caching performance.",
|
||||
"overrideDefaultConverterDescription":"Check this if you wish to use your own custom property value converter.",
|
||||
"overrideDefaultConverter":"Override Default Property Value Converter?",
|
||||
"enableCloning":"Enable Cloning?",
|
||||
"enableCloningDescription":"Enable Fieldset Cloning.",
|
||||
"fieldsetGroups":"Fieldset-grupper",
|
||||
"fieldsetGroupsDescription":"Hvis du har mange fieldsets, skal du måske overveje at gruppere dem i fieldset-vælgeren. Når du først har defineret dine grupper her, vil en gruppe-vælger dukke op i fieldset-editoren, og du kan derefter vælge grupper for alle dine fieldsets.",
|
||||
"fieldsetGroupName":"Navn",
|
||||
"addFieldsetGroup":"Tilføj gruppe",
|
||||
"enablePublishing": "Aktivér fieldset-publicering?",
|
||||
"enablePublishingDescription": "Tillad automatisk udgivelse og udløb for fieldsets",
|
||||
"publish": "Publicering",
|
||||
"publishHelpText": "Konfigurér udgivelses- og udløbsdato for dette element",
|
||||
"publishReleaseDate": "Udgivelsesdato",
|
||||
"publishExpireDate": "Udløbsdato",
|
||||
"settings": "Indstillinger",
|
||||
"enableMemberGroups": "Aktivér medlems-grupper",
|
||||
"enableMemerGroupsDescription": "Tillad at fieldsets kun vises for specifikke medlems-grupper",
|
||||
"allowedMemberGroups": "Tilladte medlems-grupper",
|
||||
"allowedMemberGroupsHelpText": "Vælg de medlems-grupper, der skal kunne se dette element. Hvis der ikke er valgt nogen, kan alle se elementet.",
|
||||
"previewFieldsetOpen": "(se eksempel)",
|
||||
"previewFieldsetHeader": "Eksempel: ",
|
||||
"previewFieldsetClose": "(luk eksempel)"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"label": "Label",
|
||||
"alias": "Alias",
|
||||
"addFieldset": "Tilføj et element",
|
||||
"hideFieldsetControls": "Skjul fieldsets?",
|
||||
"hideFieldsetControlsDescription": "Skjuler kontrollerne tilføj/fjern/sortér.",
|
||||
"toggleAdvanced": "Slå avancerede muligheder til/fra",
|
||||
"toggleAdvancedDescription": "Vis avancerede muligheder.",
|
||||
"hidePropertyLabels": "Skjul labels på egenskaber?",
|
||||
"hidePropertyLabelsDescription": "Skjuler labels på egenskaber.",
|
||||
"maxFieldsets": "Maks antal fieldsets",
|
||||
"maxFieldsetsDescription": "Hvor mange fieldsets er tilladt? Hvis der skrives '1' vil deaktivere kontrollerne. Som standard er det ubegrænset.",
|
||||
"enableMultipleFieldsets": "Aktivér flere Fieldsets?",
|
||||
"enableMultipleFieldsetsDescription": "Tillader flere typer af fieldsets i denne archetype.",
|
||||
"hideFieldsetToolbar": "Skjul Fieldset værktøjslinie?",
|
||||
"hideFieldsetToolbarDescription": "Skjuler den fieldset værktøjslinie der fremkommer når der findes mere end ét fieldset.",
|
||||
"customWrapperClass": "Egen Wrapper Class",
|
||||
"customWrapperClassDescription": "(Mulighed) Angiv din egen CSS class som tilføjes på wrapper div'en.",
|
||||
"cssFile": "CSS fil",
|
||||
"cssFileDescription": "(Mulighed) Tilføj en sti til din egen CSS fil der skal inkluderes på siden.",
|
||||
"jsFile": "JavaScript fil",
|
||||
"jsFileDescription": "(Mulighed) Tilføj en sti til din egen JavaScript fil der skal inkluderes på siden.",
|
||||
"toggleDeveloperMode": "Slå udvikler muligheder til/fra.",
|
||||
"toggleDeveloperModeDescription": "Aktivér på udvikler muligheder.",
|
||||
"configModel": "Konfigurationsmodel",
|
||||
"configModelDescription": "Vær forsigt med at redigere teksten for neden, den kontrollerer skemaet for denne archetype.",
|
||||
"helpText": "Hjælpe tekst",
|
||||
"defaultValue": "Standard værdi",
|
||||
"dataType": "Datatype",
|
||||
"required": "Påkrævet",
|
||||
"regEx": "RegEx validering",
|
||||
"properties": "Egenskaber",
|
||||
"labelTemplate": "Label skabelon",
|
||||
"select": "Vælg",
|
||||
"icon": "Ikon",
|
||||
"enableDisabling": "Aktivér fieldset-deaktivering?",
|
||||
"enableDisablingDescription": "Tillad brugere at aktivere/deaktivere individuelle fieldsets.",
|
||||
"deepDatatypeRequest":"Enable Deep Datatype Requests?",
|
||||
"deepDatatypeRequestDescription":"Allows for easier datatype interception at the cost of caching performance.",
|
||||
"overrideDefaultConverterDescription":"Check this if you wish to use your own custom property value converter.",
|
||||
"overrideDefaultConverter":"Override Default Property Value Converter?",
|
||||
"enableCloning":"Enable Cloning?",
|
||||
"enableCloningDescription":"Enable Fieldset Cloning.",
|
||||
"fieldsetGroups":"Fieldset-grupper",
|
||||
"fieldsetGroupsDescription":"Hvis du har mange fieldsets, skal du måske overveje at gruppere dem i fieldset-vælgeren. Når du først har defineret dine grupper her, vil en gruppe-vælger dukke op i fieldset-editoren, og du kan derefter vælge grupper for alle dine fieldsets.",
|
||||
"fieldsetGroupName":"Navn",
|
||||
"addFieldsetGroup":"Tilføj gruppe",
|
||||
"enablePublishing": "Aktivér fieldset-publicering?",
|
||||
"enablePublishingDescription": "Tillad automatisk udgivelse og udløb for fieldsets",
|
||||
"publish": "Publicering",
|
||||
"publishHelpText": "Konfigurér udgivelses- og udløbsdato for dette element",
|
||||
"publishReleaseDate": "Udgivelsesdato",
|
||||
"publishExpireDate": "Udløbsdato",
|
||||
"settings": "Indstillinger",
|
||||
"enableMemberGroups": "Aktivér medlems-grupper",
|
||||
"enableMemerGroupsDescription": "Tillad at fieldsets kun vises for specifikke medlems-grupper",
|
||||
"allowedMemberGroups": "Tilladte medlems-grupper",
|
||||
"allowedMemberGroupsHelpText": "Vælg de medlems-grupper, der skal kunne se dette element. Hvis der ikke er valgt nogen, kan alle se elementet.",
|
||||
"previewFieldsetOpen": "(se eksempel)",
|
||||
"previewFieldsetHeader": "Eksempel: ",
|
||||
"previewFieldsetClose": "(luk eksempel)"
|
||||
}
|
||||
+12
-1
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"label": "Label",
|
||||
"alias": "Alias",
|
||||
"addFieldset": "Add an item",
|
||||
"hideFieldsetControls": "Hide Fieldset Controls?",
|
||||
"hideFieldsetControlsDescription": "Hides the fieldset add/remove/sort controls.",
|
||||
"toggleAdvanced": "Toggle Advanced Options",
|
||||
@@ -33,5 +34,15 @@
|
||||
"select": "Select",
|
||||
"icon": "Icon",
|
||||
"enableDisabling": "Enable Fieldset Disabling?",
|
||||
"enableDisablingDescription": "Allows fieldsets to be individually enabled/disabled."
|
||||
"enableDisablingDescription": "Allows fieldsets to be individually enabled/disabled.",
|
||||
"deepDatatypeRequest":"Enable Deep Datatype Requests?",
|
||||
"deepDatatypeRequestDescription":"Allows for easier datatype interception at the cost of caching performance.",
|
||||
"overrideDefaultConverterDescription":"Check this if you wish to use your own custom property value converter.",
|
||||
"overrideDefaultConverter":"Override Default Property Value Converter?",
|
||||
"enableCloning":"Enable Cloning?",
|
||||
"enableCloningDescription":"Enable Fieldset Cloning.",
|
||||
"fieldsetGroups":"Fieldset groups",
|
||||
"fieldsetGroupsDescription":"If you have a lot of fieldsets to choose from, you may want to consider grouping them in the fieldset picker. Once you have created your groups here, a group picker will be displayed in the fieldset editor and you can assign your fieldsets to their respective groups.",
|
||||
"fieldsetGroupName":"Name",
|
||||
"addFieldsetGroup":"Add group"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"label": "Label",
|
||||
"alias": "Alias",
|
||||
"addFieldset": "Add an item",
|
||||
"hideFieldsetControls": "Hide Fieldset Controls?",
|
||||
"hideFieldsetControlsDescription": "Hides the fieldset add/remove/sort controls.",
|
||||
"toggleAdvanced": "Toggle Advanced Options",
|
||||
"toggleAdvancedDescription": "Show advanced options.",
|
||||
"hidePropertyLabels": "Hide Property Labels?",
|
||||
"hidePropertyLabelsDescription": "Hides the property labels.",
|
||||
"maxFieldsets": "Max Fieldsets",
|
||||
"maxFieldsetsDescription": "How many Fieldsets are allowed? Entering '1' will disable the controls. Default is unlimited.",
|
||||
"enableMultipleFieldsets": "Enable Multiple Fieldsets?",
|
||||
"enableMultipleFieldsetsDescription": "Allows multiple types of fieldsets within this archetype.",
|
||||
"hideFieldsetToolbar": "Hide Fieldset Toolbar?",
|
||||
"hideFieldsetToolbarDescription": "Hides the fieldset toolbar that appears when more than one fieldset model appears.",
|
||||
"customWrapperClass": "Custom Wrapper Class",
|
||||
"customWrapperClassDescription": "(Optional) Enter a custom CSS class that will be applied to the wrapper div.",
|
||||
"cssFile": "CSS File",
|
||||
"cssFileDescription": "(Optional) Enter a path for a custom CSS file to be included on the page.",
|
||||
"jsFile": "JS File",
|
||||
"jsFileDescription": "(Optional) Enter a path for a custom JS file to be included on the page.",
|
||||
"toggleDeveloperMode": "Toggle Developer Mode",
|
||||
"toggleDeveloperModeDescription": "Turn on for developer options.",
|
||||
"configModel": "Config Model",
|
||||
"configModelDescription": "Be careful editing the text below, it controls the schema for this archetype.",
|
||||
"helpText": "Help Text",
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
"required": "Required",
|
||||
"regEx": "RegEx Validation",
|
||||
"properties": "Properties",
|
||||
"labelTemplate": "Label Template",
|
||||
"select": "Select",
|
||||
"icon": "Icon",
|
||||
"enableDisabling": "Enable Fieldset Disabling?",
|
||||
"enableDisablingDescription": "Allows fieldsets to be individually enabled/disabled.",
|
||||
"deepDatatypeRequest":"Enable Deep Datatype Requests?",
|
||||
"deepDatatypeRequestDescription":"Allows for easier datatype interception at the cost of caching performance.",
|
||||
"overrideDefaultConverterDescription":"Check this if you wish to use your own custom property value converter.",
|
||||
"overrideDefaultConverter":"Override Default Property Value Converter?",
|
||||
"enableCloning":"Enable Cloning?",
|
||||
"enableCloningDescription":"Enable Fieldset Cloning.",
|
||||
"fieldsetGroups":"Fieldset groups",
|
||||
"fieldsetGroupsDescription":"If you have a lot of fieldsets to choose from, you may want to consider grouping them in the fieldset picker. Once you have created your groups here, a group picker will be displayed in the fieldset editor and you can assign your fieldsets to their respective groups.",
|
||||
"fieldsetGroupName":"Name",
|
||||
"addFieldsetGroup":"Add group"
|
||||
}
|
||||
+16
-3
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"label": "Label",
|
||||
"alias": "Alias",
|
||||
"addFieldset": "Add an item",
|
||||
"hideFieldsetControls": "Hide Fieldset Controls?",
|
||||
"hideFieldsetControlsDescription": "Hides the fieldset add/remove/sort controls.",
|
||||
"toggleAdvanced": "Toggle Advanced Options",
|
||||
@@ -10,7 +11,7 @@
|
||||
"maxFieldsets": "Max Fieldsets",
|
||||
"maxFieldsetsDescription": "How many Fieldsets are allowed? Entering '1' will disable the controls. Default is unlimited.",
|
||||
"enableMultipleFieldsets": "Enable Multiple Fieldsets?",
|
||||
"enableMultipleFieldsetsDescription": "Allows multiple types of fieldsets within this archetype.",
|
||||
"enableMultipleFieldsetsDescription": "Allows multiple types of fieldsets within this Archetype.",
|
||||
"hideFieldsetToolbar": "Hide Fieldset Toolbar?",
|
||||
"hideFieldsetToolbarDescription": "Hides the fieldset toolbar that appears when more than one fieldset model appears.",
|
||||
"customWrapperClass": "Custom Wrapper Class",
|
||||
@@ -22,7 +23,7 @@
|
||||
"toggleDeveloperMode": "Toggle Developer Mode",
|
||||
"toggleDeveloperModeDescription": "Turn on for developer options.",
|
||||
"configModel": "Config Model",
|
||||
"configModelDescription": "Be careful editing the text below, it controls the schema for this archetype.",
|
||||
"configModelDescription": "Be careful editing the text below, it controls the schema for this Archetype.",
|
||||
"helpText": "Help Text",
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
@@ -33,5 +34,17 @@
|
||||
"select": "Select",
|
||||
"icon": "Icon",
|
||||
"enableDisabling": "Enable Fieldset Disabling?",
|
||||
"enableDisablingDescription": "Allows fieldsets to be individually enabled/disabled."
|
||||
"enableDisablingDescription": "Allows fieldsets to be individually enabled/disabled.",
|
||||
"deepDatatypeRequest":"Enable Deep Datatype Requests?",
|
||||
"deepDatatypeRequestDescription":"Allows for easier datatype interception at the cost of caching performance.",
|
||||
"overrideDefaultConverterDescription":"Check this if you wish to use your own custom property value converter.",
|
||||
"overrideDefaultConverter":"Override Default Property Value Converter?",
|
||||
"enableCloning":"Enable Cloning?",
|
||||
"enableCloningDescription":"Enable Fieldset Cloning.",
|
||||
"enableCrossDragging":"Enable Cross-Archetype Dragging?",
|
||||
"enableCrossDraggingDescription":"Allows fieldsets to be dragged into other Archetypes.",
|
||||
"fieldsetGroups":"Fieldset groups",
|
||||
"fieldsetGroupsDescription":"If you have a lot of fieldsets to choose from, you may want to consider grouping them in the fieldset picker. Once you have created your groups here, a group picker will be displayed in the fieldset editor and you can assign your fieldsets to their respective groups.",
|
||||
"fieldsetGroupName":"Name",
|
||||
"addFieldsetGroup":"Add group"
|
||||
}
|
||||
|
||||
+16
-3
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"label": "Label",
|
||||
"alias": "Alias",
|
||||
"addFieldset": "Add an item",
|
||||
"hideFieldsetControls": "Hide Fieldset Controls?",
|
||||
"hideFieldsetControlsDescription": "Hides the fieldset add/remove/sort controls.",
|
||||
"toggleAdvanced": "Toggle Advanced Options",
|
||||
@@ -10,7 +11,7 @@
|
||||
"maxFieldsets": "Max Fieldsets",
|
||||
"maxFieldsetsDescription": "How many Fieldsets are allowed? Entering '1' will disable the controls. Default is unlimited.",
|
||||
"enableMultipleFieldsets": "Enable Multiple Fieldsets?",
|
||||
"enableMultipleFieldsetsDescription": "Allows multiple types of fieldsets within this archetype.",
|
||||
"enableMultipleFieldsetsDescription": "Allows multiple types of fieldsets within this Archetype.",
|
||||
"hideFieldsetToolbar": "Hide Fieldset Toolbar?",
|
||||
"hideFieldsetToolbarDescription": "Hides the fieldset toolbar that appears when more than one fieldset model appears.",
|
||||
"customWrapperClass": "Custom Wrapper Class",
|
||||
@@ -22,7 +23,7 @@
|
||||
"toggleDeveloperMode": "Toggle Developer Mode",
|
||||
"toggleDeveloperModeDescription": "Turn on for developer options.",
|
||||
"configModel": "Config Model",
|
||||
"configModelDescription": "Be careful editing the text below, it controls the schema for this archetype.",
|
||||
"configModelDescription": "Be careful editing the text below, it controls the schema for this Archetype.",
|
||||
"helpText": "Help Text",
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
@@ -33,5 +34,17 @@
|
||||
"select": "Select",
|
||||
"icon": "Icon",
|
||||
"enableDisabling": "Enable Fieldset Disabling?",
|
||||
"enableDisablingDescription": "Allows fieldsets to be individually enabled/disabled."
|
||||
"enableDisablingDescription": "Allows fieldsets to be individually enabled/disabled.",
|
||||
"deepDatatypeRequest":"Enable Deep Datatype Requests?",
|
||||
"deepDatatypeRequestDescription":"Allows for easier datatype interception at the cost of caching performance.",
|
||||
"overrideDefaultConverterDescription":"Check this if you wish to use your own custom property value converter.",
|
||||
"overrideDefaultConverter":"Override Default Property Value Converter?",
|
||||
"enableCloning":"Enable Cloning?",
|
||||
"enableCloningDescription":"Enable Fieldset Cloning.",
|
||||
"enableCrossDragging":"Enable Cross-Archetype Dragging?",
|
||||
"enableCrossDraggingDescription":"Allows fieldsets to be dragged into other Archetypes.",
|
||||
"fieldsetGroups":"Fieldset groups",
|
||||
"fieldsetGroupsDescription":"If you have a lot of fieldsets to choose from, you may want to consider grouping them in the fieldset picker. Once you have created your groups here, a group picker will be displayed in the fieldset editor and you can assign your fieldsets to their respective groups.",
|
||||
"fieldsetGroupName":"Name",
|
||||
"addFieldsetGroup":"Add group"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"label": "Label",
|
||||
"alias": "Alias",
|
||||
"addFieldset": "Add an item",
|
||||
"hideFieldsetControls": "Hide Fieldset Controls?",
|
||||
"hideFieldsetControlsDescription": "Hides the fieldset add/remove/sort controls.",
|
||||
"toggleAdvanced": "Toggle Advanced Options",
|
||||
"toggleAdvancedDescription": "Show advanced options.",
|
||||
"hidePropertyLabels": "Hide Property Labels?",
|
||||
"hidePropertyLabelsDescription": "Hides the property labels.",
|
||||
"maxFieldsets": "Max Fieldsets",
|
||||
"maxFieldsetsDescription": "How many Fieldsets are allowed? Entering '1' will disable the controls. Default is unlimited.",
|
||||
"enableMultipleFieldsets": "Enable Multiple Fieldsets?",
|
||||
"enableMultipleFieldsetsDescription": "Allows multiple types of fieldsets within this Archetype.",
|
||||
"hideFieldsetToolbar": "Hide Fieldset Toolbar?",
|
||||
"hideFieldsetToolbarDescription": "Hides the fieldset toolbar that appears when more than one fieldset model appears.",
|
||||
"customWrapperClass": "Custom Wrapper Class",
|
||||
"customWrapperClassDescription": "(Optional) Enter a custom CSS class that will be applied to the wrapper div.",
|
||||
"cssFile": "CSS File",
|
||||
"cssFileDescription": "(Optional) Enter a path for a custom CSS file to be included on the page.",
|
||||
"jsFile": "JS File",
|
||||
"jsFileDescription": "(Optional) Enter a path for a custom JS file to be included on the page.",
|
||||
"toggleDeveloperMode": "Toggle Developer Mode",
|
||||
"toggleDeveloperModeDescription": "Turn on for developer options.",
|
||||
"configModel": "Config Model",
|
||||
"configModelDescription": "Be careful editing the text below, it controls the schema for this Archetype.",
|
||||
"helpText": "Help Text",
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
"required": "Required",
|
||||
"regEx": "RegEx Validation",
|
||||
"properties": "Properties",
|
||||
"labelTemplate": "Label Template",
|
||||
"select": "Select",
|
||||
"icon": "Icon",
|
||||
"enableDisabling": "Enable Fieldset Disabling?",
|
||||
"enableDisablingDescription": "Allows fieldsets to be individually enabled/disabled.",
|
||||
"deepDatatypeRequest":"Enable Deep Datatype Requests?",
|
||||
"deepDatatypeRequestDescription":"Allows for easier datatype interception at the cost of caching performance.",
|
||||
"overrideDefaultConverterDescription":"Check this if you wish to use your own custom property value converter.",
|
||||
"overrideDefaultConverter":"Override Default Property Value Converter?",
|
||||
"enableCloning":"Enable Cloning?",
|
||||
"enableCloningDescription":"Enable Fieldset Cloning.",
|
||||
"enableCrossDragging":"Enable Cross-Archetype Dragging?",
|
||||
"enableCrossDraggingDescription":"Allows fieldsets to be dragged into other Archetypes.",
|
||||
"fieldsetGroups":"Fieldset groups",
|
||||
"fieldsetGroupsDescription":"If you have a lot of fieldsets to choose from, you may want to consider grouping them in the fieldset picker. Once you have created your groups here, a group picker will be displayed in the fieldset editor and you can assign your fieldsets to their respective groups.",
|
||||
"fieldsetGroupName":"Name",
|
||||
"addFieldsetGroup":"Add group"
|
||||
}
|
||||
+12
-1
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"label": "Label",
|
||||
"alias": "Alias",
|
||||
"addFieldset": "Add an item",
|
||||
"hideFieldsetControls": "Hide Fieldset Controls?",
|
||||
"hideFieldsetControlsDescription": "Hides the fieldset add/remove/sort controls.",
|
||||
"toggleAdvanced": "Toggle Advanced Options",
|
||||
@@ -33,5 +34,15 @@
|
||||
"select": "Select",
|
||||
"icon": "Icon",
|
||||
"enableDisabling": "Enable Fieldset Disabling?",
|
||||
"enableDisablingDescription": "Allows fieldsets to be individually enabled/disabled."
|
||||
"enableDisablingDescription": "Allows fieldsets to be individually enabled/disabled.",
|
||||
"deepDatatypeRequest":"Enable Deep Datatype Requests?",
|
||||
"deepDatatypeRequestDescription":"Allows for easier datatype interception at the cost of caching performance.",
|
||||
"overrideDefaultConverterDescription":"Check this if you wish to use your own custom property value converter.",
|
||||
"overrideDefaultConverter":"Override Default Property Value Converter?",
|
||||
"enableCloning":"Enable Cloning?",
|
||||
"enableCloningDescription":"Enable Fieldset Cloning.",
|
||||
"fieldsetGroups":"Fieldset groups",
|
||||
"fieldsetGroupsDescription":"If you have a lot of fieldsets to choose from, you may want to consider grouping them in the fieldset picker. Once you have created your groups here, a group picker will be displayed in the fieldset editor and you can assign your fieldsets to their respective groups.",
|
||||
"fieldsetGroupName":"Name",
|
||||
"addFieldsetGroup":"Add group"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"label": "Label",
|
||||
"alias": "Alias",
|
||||
"addFieldset": "Add an item",
|
||||
"hideFieldsetControls": "Hide Fieldset Controls?",
|
||||
"hideFieldsetControlsDescription": "Hides the fieldset add/remove/sort controls.",
|
||||
"toggleAdvanced": "Toggle Advanced Options",
|
||||
"toggleAdvancedDescription": "Show advanced options.",
|
||||
"hidePropertyLabels": "Hide Property Labels?",
|
||||
"hidePropertyLabelsDescription": "Hides the property labels.",
|
||||
"maxFieldsets": "Max Fieldsets",
|
||||
"maxFieldsetsDescription": "How many Fieldsets are allowed? Entering '1' will disable the controls. Default is unlimited.",
|
||||
"enableMultipleFieldsets": "Enable Multiple Fieldsets?",
|
||||
"enableMultipleFieldsetsDescription": "Allows multiple types of fieldsets within this archetype.",
|
||||
"hideFieldsetToolbar": "Hide Fieldset Toolbar?",
|
||||
"hideFieldsetToolbarDescription": "Hides the fieldset toolbar that appears when more than one fieldset model appears.",
|
||||
"customWrapperClass": "Custom Wrapper Class",
|
||||
"customWrapperClassDescription": "(Optional) Enter a custom CSS class that will be applied to the wrapper div.",
|
||||
"cssFile": "CSS File",
|
||||
"cssFileDescription": "(Optional) Enter a path for a custom CSS file to be included on the page.",
|
||||
"jsFile": "JS File",
|
||||
"jsFileDescription": "(Optional) Enter a path for a custom JS file to be included on the page.",
|
||||
"toggleDeveloperMode": "Toggle Developer Mode",
|
||||
"toggleDeveloperModeDescription": "Turn on for developer options.",
|
||||
"configModel": "Config Model",
|
||||
"configModelDescription": "Be careful editing the text below, it controls the schema for this archetype.",
|
||||
"helpText": "Help Text",
|
||||
"defaultValue": "Default Value",
|
||||
"dataType": "DataType",
|
||||
"required": "Required",
|
||||
"regEx": "RegEx Validation",
|
||||
"properties": "Properties",
|
||||
"labelTemplate": "Label Template",
|
||||
"select": "Select",
|
||||
"icon": "Icon",
|
||||
"enableDisabling": "Enable Fieldset Disabling?",
|
||||
"enableDisablingDescription": "Allows fieldsets to be individually enabled/disabled.",
|
||||
"deepDatatypeRequest":"Enable Deep Datatype Requests?",
|
||||
"deepDatatypeRequestDescription":"Allows for easier datatype interception at the cost of caching performance.",
|
||||
"overrideDefaultConverterDescription":"Check this if you wish to use your own custom property value converter.",
|
||||
"overrideDefaultConverter":"Override Default Property Value Converter?",
|
||||
"enableCloning":"Enable Cloning?",
|
||||
"enableCloningDescription":"Enable Fieldset Cloning.",
|
||||
"fieldsetGroups":"Fieldset groups",
|
||||
"fieldsetGroupsDescription":"If you have a lot of fieldsets to choose from, you may want to consider grouping them in the fieldset picker. Once you have created your groups here, a group picker will be displayed in the fieldset editor and you can assign your fieldsets to their respective groups.",
|
||||
"fieldsetGroupName":"Name",
|
||||
"addFieldsetGroup":"Add group"
|
||||
}
|
||||
+12
-1
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"label": "Label",
|
||||
"alias": "Alias",
|
||||
"addFieldset": "Add an item",
|
||||
"hideFieldsetControls": "Hide Fieldset Controls?",
|
||||
"hideFieldsetControlsDescription": "Hides the fieldset add/remove/sort controls.",
|
||||
"toggleAdvanced": "Toggle Advanced Options",
|
||||
@@ -33,5 +34,15 @@
|
||||
"select": "Select",
|
||||
"icon": "Icon",
|
||||
"enableDisabling": "Enable Fieldset Disabling?",
|
||||
"enableDisablingDescription": "Allows fieldsets to be individually enabled/disabled."
|
||||
"enableDisablingDescription": "Allows fieldsets to be individually enabled/disabled.",
|
||||
"deepDatatypeRequest":"Enable Deep Datatype Requests?",
|
||||
"deepDatatypeRequestDescription":"Allows for easier datatype interception at the cost of caching performance.",
|
||||
"overrideDefaultConverterDescription":"Check this if you wish to use your own custom property value converter.",
|
||||
"overrideDefaultConverter":"Override Default Property Value Converter?",
|
||||
"enableCloning":"Enable Cloning?",
|
||||
"enableCloningDescription":"Enable Fieldset Cloning.",
|
||||
"fieldsetGroups":"Fieldset groups",
|
||||
"fieldsetGroupsDescription":"If you have a lot of fieldsets to choose from, you may want to consider grouping them in the fieldset picker. Once you have created your groups here, a group picker will be displayed in the fieldset editor and you can assign your fieldsets to their respective groups.",
|
||||
"fieldsetGroupName":"Name",
|
||||
"addFieldsetGroup":"Add group"
|
||||
}
|
||||
|
||||
+12
-1
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"label": "Label",
|
||||
"alias": "Alias",
|
||||
"addFieldset": "Add an item",
|
||||
"hideFieldsetControls": "Hide Fieldset Controls?",
|
||||
"hideFieldsetControlsDescription": "Hides the fieldset add/remove/sort controls.",
|
||||
"toggleAdvanced": "Toggle Advanced Options",
|
||||
@@ -33,5 +34,15 @@
|
||||
"select": "Select",
|
||||
"icon": "Icon",
|
||||
"enableDisabling": "Enable Fieldset Disabling?",
|
||||
"enableDisablingDescription": "Allows fieldsets to be individually enabled/disabled."
|
||||
"enableDisablingDescription": "Allows fieldsets to be individually enabled/disabled.",
|
||||
"deepDatatypeRequest":"Enable Deep Datatype Requests?",
|
||||
"deepDatatypeRequestDescription":"Allows for easier datatype interception at the cost of caching performance.",
|
||||
"overrideDefaultConverterDescription":"Check this if you wish to use your own custom property value converter.",
|
||||
"overrideDefaultConverter":"Override Default Property Value Converter?",
|
||||
"enableCloning":"Enable Cloning?",
|
||||
"enableCloningDescription":"Enable Fieldset Cloning.",
|
||||
"fieldsetGroups":"Fieldset groups",
|
||||
"fieldsetGroupsDescription":"If you have a lot of fieldsets to choose from, you may want to consider grouping them in the fieldset picker. Once you have created your groups here, a group picker will be displayed in the fieldset editor and you can assign your fieldsets to their respective groups.",
|
||||
"fieldsetGroupName":"Name",
|
||||
"addFieldsetGroup":"Add group"
|
||||
}
|
||||
|
||||
+12
-1
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"label": "Label",
|
||||
"alias": "Alias",
|
||||
"addFieldset": "Add an item",
|
||||
"hideFieldsetControls": "Hide Fieldset Controls?",
|
||||
"hideFieldsetControlsDescription": "Hides the fieldset add/remove/sort controls.",
|
||||
"toggleAdvanced": "Toggle Advanced Options",
|
||||
@@ -33,5 +34,15 @@
|
||||
"select": "Select",
|
||||
"icon": "Icon",
|
||||
"enableDisabling": "Enable Fieldset Disabling?",
|
||||
"enableDisablingDescription": "Allows fieldsets to be individually enabled/disabled."
|
||||
"enableDisablingDescription": "Allows fieldsets to be individually enabled/disabled.",
|
||||
"deepDatatypeRequest":"Enable Deep Datatype Requests?",
|
||||
"deepDatatypeRequestDescription":"Allows for easier datatype interception at the cost of caching performance.",
|
||||
"overrideDefaultConverterDescription":"Check this if you wish to use your own custom property value converter.",
|
||||
"overrideDefaultConverter":"Override Default Property Value Converter?",
|
||||
"enableCloning":"Enable Cloning?",
|
||||
"enableCloningDescription":"Enable Fieldset Cloning.",
|
||||
"fieldsetGroups":"Fieldset groups",
|
||||
"fieldsetGroupsDescription":"If you have a lot of fieldsets to choose from, you may want to consider grouping them in the fieldset picker. Once you have created your groups here, a group picker will be displayed in the fieldset editor and you can assign your fieldsets to their respective groups.",
|
||||
"fieldsetGroupName":"Name",
|
||||
"addFieldsetGroup":"Add group"
|
||||
}
|
||||
|
||||
+12
-1
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"label": "Label",
|
||||
"alias": "Alias",
|
||||
"addFieldset": "Add an item",
|
||||
"hideFieldsetControls": "Hide Fieldset Controls?",
|
||||
"hideFieldsetControlsDescription": "Hides the fieldset add/remove/sort controls.",
|
||||
"toggleAdvanced": "Toggle Advanced Options",
|
||||
@@ -33,5 +34,15 @@
|
||||
"select": "Select",
|
||||
"icon": "Icon",
|
||||
"enableDisabling": "Enable Fieldset Disabling?",
|
||||
"enableDisablingDescription": "Allows fieldsets to be individually enabled/disabled."
|
||||
"enableDisablingDescription": "Allows fieldsets to be individually enabled/disabled.",
|
||||
"deepDatatypeRequest":"Enable Deep Datatype Requests?",
|
||||
"deepDatatypeRequestDescription":"Allows for easier datatype interception at the cost of caching performance.",
|
||||
"overrideDefaultConverterDescription":"Check this if you wish to use your own custom property value converter.",
|
||||
"overrideDefaultConverter":"Override Default Property Value Converter?",
|
||||
"enableCloning":"Enable Cloning?",
|
||||
"enableCloningDescription":"Enable Fieldset Cloning.",
|
||||
"fieldsetGroups":"Fieldset groups",
|
||||
"fieldsetGroupsDescription":"If you have a lot of fieldsets to choose from, you may want to consider grouping them in the fieldset picker. Once you have created your groups here, a group picker will be displayed in the fieldset editor and you can assign your fieldsets to their respective groups.",
|
||||
"fieldsetGroupName":"Name",
|
||||
"addFieldsetGroup":"Add group"
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user