Compare commits

...

647 Commits

Author SHA1 Message Date
Kevin Giszewski a4c1a59e23 Merge pull request #436 from kgiszewski/feature/slow-the-updates-roll
Feature/slow the updates roll
2017-10-07 07:10:36 -04:00
Kevin Giszewski e164be1823 Merge logic 2017-10-03 13:31:43 -04:00
Kevin Giszewski f32451fffa Clean up private var 2017-10-03 13:28:25 -04:00
Kevin Giszewski a541dbd038 Limit the version check to once every 7 days (unless the app is reloaded) 2017-10-03 13:27:03 -04:00
Kevin Giszewski 69e0bb70e5 Fix scrunchy fieldset picker titles 2017-10-03 11:07:10 -04:00
Kevin Giszewski c22a2623c2 Merge pull request #434 from ceee/ui-refactor
Update UI to better match Grid & Nested Content
2017-10-03 08:56:52 -04:00
swcs c229cc9953 correct layout for cross dragging between archetype instances 2017-10-03 14:32:34 +02:00
swcs 7d155ee176 force visibility of editor controls if a fieldset collapser is open 2017-10-02 15:49:37 +02:00
swcs 93659e5a22 increase char limit for RTE label generator from 50 to 160 2017-10-02 15:40:04 +02:00
swcs 46bbf24edf limit fieldset label to 2 lines 2017-09-29 10:34:34 +02:00
swcs da1057c681 fix style for nested archetype fieldsets 2017-09-28 14:14:16 +02:00
swcs 81881a5734 allow 100% width for fieldset labels and add background for controls on the right 2017-09-28 14:05:09 +02:00
swcs 25678a812c new empty content display and add button 2017-09-26 11:25:51 +02:00
Kevin Giszewski ec2edce74c Bump version 2017-09-25 13:31:52 -04:00
Kevin Giszewski 4756551518 Merge pull request #433 from Nicholas-Westby/fix/432-resolve-label-templates
Fix for label templates sometimes not resolving: https://github.com/k…
2017-09-25 08:28:23 -04:00
Nicholas-Westby e053b42950 Fix for label templates sometimes not resolving: https://github.com/kgiszewski/Archetype/issues/432 2017-09-23 17:16:50 -07:00
swcs ff21951ea1 make the container/boundaries for the fieldset collapser more visible 2017-09-21 14:22:21 +02:00
swcs 18935b4a69 update control icons and do only show them on fieldset hover 2017-09-21 13:41:47 +02:00
swcs cd93e17494 improve fieldset list layout and spacing 2017-09-21 13:15:58 +02:00
Kevin Giszewski 3a2190b232 Merge pull request #431 from kgiszewski/feature/letstryagain
Feature/letstryagain
2017-09-20 08:03:00 -04:00
Kevin Giszewski 46b0396652 Use a quicker cache lookup 2017-09-19 08:52:51 -04:00
Kevin Giszewski 0c3fcce58b Add args example 2017-09-15 15:50:39 -04:00
Kevin Giszewski cef7a36bd4 I remember adding these and now I think that was dumb. We should be injecting these :) 2017-09-15 13:41:24 -04:00
Kevin Giszewski 03d511ca80 Update sampleLabelHelpers and inject entityResource instead of off the scope 2017-09-15 13:39:18 -04:00
Kevin Giszewski 123546b11c Promise fixes 2017-09-15 12:46:33 -04:00
Kevin Giszewski 4aa6b83d82 Move to all promises, this is WIP 2017-09-15 10:58:04 -04:00
Kevin Giszewski 6f3a414c4d Handle native stuff a bit differently 2017-09-13 22:19:09 -04:00
Kevin Giszewski 4443d628dc Maybe works? 2017-09-13 21:56:43 -04:00
Kevin Giszewski 0f9a44c539 RTE is working, but not the UrlPicker one 2017-09-13 18:18:29 -04:00
Kevin Giszewski dd47218bd3 Add an asset only task 2017-09-13 17:15:11 -04:00
Kevin Giszewski 5e3e37af31 Update package.nuspec 2017-09-12 10:57:13 -04:00
Kevin Giszewski dbf1bffe34 Update package_binaries.nuspec 2017-09-12 10:56:53 -04:00
Kevin Giszewski cbf87264ac Update package_courier.nuspec 2017-09-12 10:56:41 -04:00
Kevin Giszewski 353c3da22a Update Information Collection Disclosure.md 2017-09-12 10:27:07 -04:00
Kevin Giszewski 9d15e0c696 Update README.md 2017-09-12 10:26:10 -04:00
Kevin Giszewski 7dc7b8f938 Update README.md 2017-09-12 10:25:26 -04:00
Kevin Giszewski f8302b0926 Update README.md 2017-09-12 10:22:12 -04:00
Kevin Giszewski 1cb3f4e266 Merge branch 'master' of https://github.com/kgiszewski/Archetype 2017-09-12 10:16:40 -04:00
Kevin Giszewski d2b7a9a92b Delete tonic_logo_50.png 2017-09-12 10:16:24 -04:00
Kevin Giszewski 245f4ed972 Update TOS -> Disclosure 2017-09-12 10:15:06 -04:00
Kevin Giszewski 19ef383a71 Update Information Collection Disclosure.md 2017-09-12 10:12:57 -04:00
Kevin Giszewski af2287d2fc Add files via upload 2017-09-12 10:12:43 -04:00
Kevin Giszewski e4c206211f Delete optout2.png 2017-09-12 10:12:34 -04:00
Kevin Giszewski 57a199d235 Update Information Collection Disclosure.md 2017-09-12 10:11:45 -04:00
Kevin Giszewski 2a98005ae7 Add files via upload 2017-09-12 10:11:27 -04:00
Kevin Giszewski 69a7256538 Delete optout.png 2017-09-12 10:10:53 -04:00
Kevin Giszewski 38dc405183 Rename Information Collection Disclosure to Information Collection Disclosure.md 2017-09-12 10:06:17 -04:00
Kevin Giszewski d6874e7cd8 Update Information Collection Disclosure 2017-09-12 10:02:09 -04:00
Kevin Giszewski c1e732e3de Update and rename Terms of Service.md to Information Collection Disclosure 2017-09-12 10:01:42 -04:00
Kevin Giszewski 02ffe4db4a Update Terms of Service.md 2017-09-12 09:50:46 -04:00
Kevin Giszewski c79be2f6db Update Terms of Service.md 2017-09-12 09:49:33 -04:00
Kevin Giszewski f0c15ade5d Update Terms of Service.md 2017-09-12 09:48:02 -04:00
Kevin Giszewski 9f8acedf6f Add files via upload 2017-09-12 09:46:18 -04:00
Kevin Giszewski aba3bdd2c4 Update Terms of Service.md 2017-09-12 09:44:59 -04:00
Kevin Giszewski de491f9687 Update Terms of Service.md 2017-09-12 09:43:57 -04:00
Kevin Giszewski 2becf8a1ba Merge pull request #426 from kgiszewski/feature/version-check
Feature/version check
2017-09-12 09:31:03 -04:00
Kevin Giszewski 68a5a9893d Update Sponsors.md 2017-09-08 09:15:11 -04:00
Kevin Giszewski 3ed08c447c Update Sponsors.md 2017-09-08 09:14:44 -04:00
Kevin Giszewski 9a2e14d8f6 Add sponsors 2017-09-08 09:09:38 -04:00
Kevin Giszewski d557ec1edb Update README.md 2017-09-08 09:07:30 -04:00
Kevin Giszewski 4fb7cdc5e5 Create Sponsors.md 2017-09-08 09:06:29 -04:00
Kevin Giszewski 5fa225b460 Update README.md 2017-09-08 09:05:34 -04:00
Kevin Giszewski b1f8c6a732 Merge pull request #425 from Nicholas-Westby/feature/422-label-template-enhancements
Feature/422 label template enhancements
2017-09-07 14:26:48 -04:00
Kevin Giszewski 7d8a6e28fa Test Sponsors 2017-09-07 14:15:28 -04:00
Kevin Giszewski 6a9c56df58 Add locking to the file saving. Update casing on English lang files. 2017-09-07 13:13:37 -04:00
Nicholas-Westby fa265d3019 Avoid exception when there is no label template. 2017-09-07 08:30:09 -07:00
Kevin Giszewski 078f4a506e Add obfuscation 2017-09-07 11:01:29 -04:00
Kevin Giszewski 42661c27f4 Update archetype.config.html 2017-09-07 09:21:48 -04:00
Kevin Giszewski b398e0e677 Merge pull request #427 from GertyEngrie/feature/required-property-indication
Indicate in the datatype configuration if a property is required or not
2017-09-07 09:17:36 -04:00
Kevin Giszewski a54170b915 Naming is hard. 2017-09-07 09:08:47 -04:00
Kevin Giszewski 757ba890f5 Update links and blurb in the config 2017-09-07 09:03:39 -04:00
Kevin Giszewski a127dac03a Move off the web.config in favor of an Archetype config 2017-09-07 08:55:26 -04:00
Gerty Engrie 62e481d49c Indicate in the datatype configuration if a property is required or not 2017-09-07 11:30:21 +02:00
Kevin Giszewski 77ec2d7a9c Update meta.json 2017-09-06 21:22:00 -04:00
Kevin Giszewski 0d55f0ed86 Add a URL to the notification 2017-09-06 21:00:32 -04:00
Kevin Giszewski 6a7ac205bc Update the url to call and use JSON Convert 2017-09-06 19:53:25 -04:00
Kevin Giszewski 1cb2139137 More WIP 2017-09-06 18:32:48 -04:00
Kevin Giszewski b14645f13f Update Terms of Service.md 2017-09-06 17:25:05 -04:00
Kevin Giszewski b8741726bc Update README.md 2017-09-06 17:21:35 -04:00
Kevin Giszewski d392c4f705 Update Terms of Service.md 2017-09-06 17:20:16 -04:00
Kevin Giszewski 119b0c7680 Create Terms of Service.md 2017-09-06 17:19:43 -04:00
Kevin Giszewski b9179f4140 WIP on version checking 2017-09-06 12:20:52 -04:00
Nicholas-Westby d46d64c52b Allow for other data types to be used with label template functions. 2017-09-06 08:18:43 -07:00
Nicholas-Westby 45318cf061 Merge remote-tracking branch 'upstream/master' into feature/422-label-template-enhancements 2017-09-05 21:01:55 -07:00
Nicholas-Westby b9abf0d6a3 Allow for services to be injected into label template functions.
Allow the value returned from a label template function to be recursively resolved until it finally becomes a string.
2017-09-05 20:51:45 -07:00
Nicholas-Westby e00229984c Label templates can now return a promise that eventually resolves to a string. 2017-09-05 19:39:33 -07:00
Nicholas-Westby 155f212062 New approach to splitting the label template (will make the upcoming promises work easier). In short, each substring is stored into an array, those items are modified, then when all the modifications are done the substrings are combined again. 2017-09-04 20:26:16 -07:00
Nicholas-Westby 86a8112fbd Fixed regex so it doesn't match empty strings.
Removed unused variable.
2017-09-04 19:15:49 -07:00
Nicholas-Westby 810fa95c65 Removed some extraneous and probably buggy code related to label templates. 2017-09-04 19:06:12 -07:00
Nicholas-Westby 9bcd9d67ae Update the Archetype controller to allow for fieldset titles to be loaded using promises (still need to actually allow for promises). 2017-09-04 15:49:30 -07:00
Kevin Giszewski bae1ee508b Update README.md 2017-09-04 17:26:56 -04:00
Kevin Giszewski 20b6a78af1 Update some stuffs for nuget 2017-08-18 09:20:45 -04:00
Kevin Giszewski 014b407abb Let's do purple 2017-08-18 09:03:03 -04:00
Kenn Jacobsen 5aa16a6636 Bump package version 2017-08-18 08:10:43 +02:00
Kenn Jacobsen 7206bba46a Merge pull request #423 from kjac/min-fieldsets-feature
Add minimum fieldsets feature
2017-08-15 12:43:07 +02:00
Kenn Jacobsen af9db94fb6 Merge pull request #421 from kjac/Fix-418
Fix #418
2017-08-09 13:37:50 +02:00
Kenn Jacobsen d2014be81b Fix #418
Don't let the entire published content conversion break if one property
no longer exists.
2017-08-09 13:36:59 +02:00
Kenn Jacobsen 01b8b3b508 Merge remote-tracking branch 'refs/remotes/origin/master' into min-fieldsets-feature 2017-08-09 13:24:35 +02:00
Kenn Jacobsen 734125fa25 Merge remote-tracking branch 'refs/remotes/kgiszewski/master' 2017-08-09 13:24:06 +02:00
Kenn Jacobsen 76678f538d Merge pull request #420 from kjac/fix-414
Fix #414
2017-08-09 13:22:55 +02:00
Kenn Jacobsen 7fe23fdf4c Fix #414
Using ng-src instead of src fixes the issue.
2017-08-09 13:22:05 +02:00
Kenn Jacobsen c956c12cdf Merge remote-tracking branch 'refs/remotes/kgiszewski/master' 2017-08-09 13:16:19 +02:00
Kenn Jacobsen 8706feb882 Merge pull request #419 from kjac/fix-417
Tested with a custom property editor to make sure the JSON default value works.
2017-08-09 12:58:59 +02:00
Kenn Jacobsen c8364986a2 Fix #417
Don't turn an object into a string if it's not...
2017-08-09 12:49:47 +02:00
Kenn Jacobsen 4d24150bdc Merge remote-tracking branch 'refs/remotes/kgiszewski/master' 2017-08-09 12:48:17 +02:00
kjac a16c4b4da9 Merge remote-tracking branch 'refs/remotes/kgiszewski/master' into min-fieldsets-feature 2017-07-28 16:09:49 +02:00
Kevin Giszewski 75a312c309 Update README.md 2017-06-26 09:12:11 -04:00
Kenn Jacobsen aa6505d7f6 Merge pull request #412 from kjac/master
Bump package version
2017-06-13 08:41:09 +02:00
Kenn Jacobsen 6ed7af28bc Bump package version 2017-06-13 08:38:31 +02:00
Kenn Jacobsen 526f4c147a Merge remote-tracking branch 'refs/remotes/kgiszewski/master' 2017-06-13 08:28:22 +02:00
Kenn Jacobsen bb0df72dc7 Merge pull request #411 from kjac/fieldset-preview-image
Add fieldset image previews
2017-06-13 08:27:39 +02:00
Kenn Jacobsen 3cba5677bf Whoops... the preview image shouldn't be mandatory 2017-06-13 08:25:05 +02:00
kjac c4f88ab528 Remove max width comment 2017-06-12 22:29:16 +02:00
kjac 7bc9584940 Add min fieldsets handling 2017-06-12 22:26:03 +02:00
kjac 17be4b4253 Merge remote-tracking branch 'refs/remotes/origin/master' into fieldset-preview-image 2017-06-12 22:11:07 +02:00
kjac 2db196af6a Merge remote-tracking branch 'refs/remotes/kgiszewski/master' 2017-06-12 22:09:29 +02:00
Kenn Jacobsen b4b27cd1f8 Merge pull request #410 from kjac/mandatory-validation-disabled-fieldsets
Handle disabled fieldsets in mandatory validation
2017-06-12 22:07:02 +02:00
kjac a2cc052944 Handle disabled fieldsets in mandatory validation
Disabled fieldsets should not count when performing mandatory
validation. This ensures they aren't.
2017-06-12 22:04:46 +02:00
kjac 4d8a4f0b12 Merge remote-tracking branch 'refs/remotes/origin/master' into fieldset-preview-image 2017-06-11 22:10:07 +02:00
kjac 743f37c45f Merge remote-tracking branch 'refs/remotes/kgiszewski/master' 2017-06-11 22:09:40 +02:00
Kenn Jacobsen 1ba45969ee Merge pull request #409 from kjac/multiple-open-fieldsets
Enable multiple open fieldsets by datatype configuration. It's default enabled on newly created Archetypes.
2017-06-11 22:08:48 +02:00
kjac 349d6f69b3 Enable multiple open fieldsets
See #196
2017-06-11 22:06:14 +02:00
kjac 9431a70156 Merge remote-tracking branch 'refs/remotes/origin/master' into fieldset-preview-image 2017-06-11 21:38:04 +02:00
kjac ab780f72a4 Merge remote-tracking branch 'refs/remotes/kgiszewski/master' 2017-06-11 21:37:39 +02:00
Kenn Jacobsen 7d01be305f Merge pull request #408 from kjac/fix-mandatory-validation
Fix mandatory validation: The mandatory validation implementation prevents a valid Archetype from
being submitted on the first go because the mandatory validation isn't
initialized.
2017-06-11 21:36:34 +02:00
kjac 694b932e37 Fix mandatory validation issue
The mandatory validation implementation prevents a valid Archetype from
being submitted on the first go because the mandatory validation isn't
initialized.
2017-06-11 21:35:31 +02:00
kjac a4f6334761 Merge branch 'master' into fieldset-preview-image 2017-06-11 16:18:52 +02:00
kjac 9316e7c3f6 Merge remote-tracking branch 'refs/remotes/kgiszewski/master' 2017-06-11 16:17:46 +02:00
Kenn Jacobsen 8bc6c17921 Merge pull request #407 from kjac/styling-for-7.6
Styling for 7.6: Make the "add new item" button look ok in 7.6 + hide the "drag into"
area for non cross draggable Archetypes.
2017-06-11 16:16:53 +02:00
kjac 1161c7e6da A bit of styling
Make the "add new item" button look ok in 7.6 + hide the "drag into"
area for non cross draggable Archetypes.
2017-06-11 16:14:58 +02:00
kjac 93db3eb2ee Merge remote-tracking branch 'refs/remotes/kgiszewski/master' 2017-06-11 16:07:24 +02:00
Kenn Jacobsen b7b166562f Merge pull request #406 from kjac/collapsing-dollar-signs
Collapsing dollar signs
2017-06-11 16:05:26 +02:00
kjac e3c4c91de1 Fix #387 2017-06-11 16:03:56 +02:00
kjac f79849cf8a Open preview image in a new window when clicked 2017-06-10 08:49:59 +02:00
kjac f0b27e1507 Merge remote-tracking branch 'refs/remotes/origin/master' into fieldset-preview-image 2017-06-10 08:26:28 +02:00
kjac 42e92a4e74 Merge remote-tracking branch 'refs/remotes/kgiszewski/master' 2017-06-10 08:26:06 +02:00
Kenn Jacobsen 2c363a5d37 Merge pull request #405 from kjac/mandatory-validation
Mandatory validation - fixes #395
2017-06-09 21:19:32 +02:00
kjac 738e9282b6 Handle mandatory validation
Don't allow submission of an empty Archetype if the property is set to
mandatory
2017-06-09 21:11:11 +02:00
kjac 20fa1efc8e A bit more styling + localization 2017-06-09 21:04:44 +02:00
kjac 718f2deb47 Add preview image to fieldsets
See #374
2017-06-09 20:19:17 +02:00
kjac 1cea5d156a Merge remote-tracking branch 'refs/remotes/kgiszewski/master' 2017-06-08 16:46:00 +02:00
Kenn Jacobsen 109d4c7708 Merge pull request #404 from kjac/label-templates-for-v2-pickers
Label templates for the V2 pickers
2017-06-08 16:37:50 +02:00
Kenn Jacobsen 8306be60de Merge pull request #403 from kjac/lazy-load-configuration
Lazy load configuration
2017-06-08 16:36:52 +02:00
Kenn Jacobsen 27d0cb742b Label templates for the V2 pickers
..and also for the old content picker (it was missing for whatever
reason) - fixes #402
2017-06-08 09:02:31 +02:00
kjac 62a250cd83 Lazy load fieldsets in configuration
Fixes #393
2017-06-07 23:07:40 +02:00
kjac 6f94d608db Merge remote-tracking branch 'refs/remotes/kgiszewski/master' 2017-06-07 20:56:35 +02:00
Kenn Jacobsen 854e9873c8 Merge pull request #401 from kjac/image-cropper-and-upload-76
Adjust to 7.6 scheme for upload and image croppers
2017-06-07 17:56:20 +02:00
Kenn Jacobsen 2a6d5eaddf Merge pull request #400 from kjac/fix-upload-and-image-cropper-again
Fix upload and image cropper (again)
2017-06-07 17:48:23 +02:00
kjac 3d7ddb58c2 Adjust to 7.6 scheme for upload and image croppers
Fixes #397, at least for newly created sites.
2017-06-06 23:14:40 +02:00
kjac 4c7496840d Fix upload and image cropper (again)
Fixes #384, #389 and #394
2017-06-06 22:41:04 +02:00
Kevin Giszewski d816103981 Merge pull request #399 from codedemonuk/patch-1
Subheadings were not being rendered correctly in Readme
2017-05-29 11:14:18 -04:00
Pervez Choudhury b38ccc12f6 Subheadings were not being rendered correctly 2017-05-28 17:48:44 +01:00
Kevin Giszewski e1deba5b95 Update LICENSE 2017-02-16 12:53:33 -05:00
Kevin Giszewski 5bce4e856a Merge pull request #386 from kgiszewski/fix-385
Fix #385
2017-02-16 12:42:55 -05:00
Kevin Giszewski 6f4cb1e609 Merge pull request #379 from leekelleher/feature/typeconverter
TypeConverter for ArchetypeModel
2017-02-16 12:42:44 -05:00
Kenn Jacobsen 033cbbc8f6 Fix #385 2017-02-16 15:05:21 +01:00
Kenn Jacobsen 7ee3cfca5c Merge pull request #378 from Nicholas-Westby/fix/372-drag-drop-broken
Fix for drag & drop failing when dropping fieldset in the same Archet…
2017-02-16 12:16:44 +01:00
Kenn Jacobsen e9b478c186 Fix #384
For some reason Umbraco has started lowercasing the names of uploaded
files. This fixes the problem by ignoring case when looking for the
uploaded files.
2017-02-15 11:17:01 +01:00
leekelleher 21e784424f TypeConverter for ArchetypeModel
Added a TypeConverter for both `ArchetypeModel` and `ArchetypeFieldsetModel`, so that they can be converted to their `IPublishedContent` equivalent.

Example usage would be, when you would typically do this...

```csharp
var items = Model.Content.GetPropertyValue<ArchetypeModel>myArchetypeAlias");
```

You can now do this...

```csharp
var items = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("myArchetypeAlias");
```

I know it seems more verbose, but the idea is that this could be hot-swappable with other property-editors, such as Nested Content. The frontend/code would deal purely with `IPublishedContent` objects.

---

Also included unit-tests that run via Umbraco Core's `TryConvertTo` extension method, (which is what `Content.GetPropertyValue<T>` uses internally in Umbraco).

There's a small caveat with the TypeConverter for `ArchetypeFieldsetModel`, I had to explicitly reject `typeof(string)`, otherwise the JSON deserializer fails (in `ArchetypeHelper.DeserializeJsonToArchetype`).
All other unit-tests still pass.
2016-10-19 20:26:46 +01:00
Nicholas-Westby 155355aa00 Fix for drag & drop failing when dropping fieldset in the same Archetype and the max fieldsets is reached: https://github.com/kgiszewski/Archetype/issues/372 2016-09-14 22:08:04 -07:00
kgiszewski abf6917b1c bump to v1.13.1 2016-06-26 12:10:11 -04:00
kgiszewski 40ad701f7f Merge branch 'master' into pr/365 2016-06-26 12:05:18 -04:00
Kevin Giszewski a8113f926c Merge pull request #369 from kipusoep/master
Fixed #368
2016-06-16 16:21:21 -04:00
Kevin Giszewski 3c527396de Merge pull request #364 from Nicholas-Westby/fix/362-drag-fieldset-undefined
Fix for error during Archetype drags when there are rich text editors…
2016-06-16 16:12:33 -04:00
Stefan Kip 59bf66dcd1 Fixed #368 2016-06-16 20:11:02 +02:00
Nicholas-Westby c125042a86 Avoid fieldsets that can't be expanded: https://github.com/imulus/Archetype/issues/363 2016-05-20 21:38:39 -07:00
Nicholas-Westby 85ea472129 Fix for error during Archetype drags when there are rich text editors outside of Archetype: https://github.com/imulus/Archetype/issues/362 2016-05-18 20:03:05 -07:00
kgiszewski f541b50b82 Merge branch 'master' into pr/356
Conflicts:
	app/Umbraco/Umbraco.Archetype/Models/ArchetypePreValue.cs
	app/controllers/config.controller.js
	app/views/archetype.config.fieldset.dialog.html
2016-05-13 10:07:18 -04:00
Nicholas-Westby 5767ea97d1 Workaround for .sortable("instance") not working on older versions of Umbraco. 2016-05-11 21:19:09 -07:00
Nicholas-Westby e1fa7a3271 Fixed recursion error and tidied up validation logic. 2016-05-07 15:48:39 -07:00
Nicholas-Westby c2e97e28ce Disable sortables for Archetypes that can't have the currently dragged fieldset dropped onto them. 2016-05-07 14:54:30 -07:00
Nicholas-Westby eda9bab02f Ensure the property alias is unique when dragging between Archetypes. 2016-05-07 12:45:34 -07:00
Nicholas-Westby ce3cecbec9 Fix for incorrect validation errors. 2016-05-05 21:52:03 -07:00
Nicholas-Westby ef5faae254 Allow the last fieldset to be dropped back to its origin list. 2016-05-05 21:18:08 -07:00
Nicholas-Westby 547473e92c Account for the possibility that the "tinyMCE" variable may not exist. 2016-05-05 20:20:44 -07:00
Nicholas-Westby 9857059906 Ensured the temporary ID is unique when cloning fieldsets. 2016-05-05 20:05:20 -07:00
Nicholas-Westby 7f7b054c14 Clear errors on the target Archetype too. 2016-05-04 21:28:16 -07:00
Nicholas-Westby a40d95250e Clear out errors of nested Archetypes on drop. 2016-05-04 21:15:36 -07:00
Nicholas-Westby 1e6004d3fa Another RTE fix.
Improved handling of validations when moving fieldsets (recursively mark Archetypes as valid).
2016-05-04 20:58:26 -07:00
Nicholas-Westby 0671403732 Fix for rich text editors when dragging between Archetypes. 2016-05-03 21:59:04 -07:00
kjac 8e00914370 More code style fixes 2016-05-03 20:17:45 +02:00
kjac 104c369bcc Fix some code style issues 2016-05-03 20:15:23 +02:00
kjac 4c02cf2921 Merge remote-tracking branch 'refs/remotes/origin/master' into allowed-member-groups 2016-05-03 19:44:59 +02:00
kjac 74470b8e8f Merge remote-tracking branch 'refs/remotes/imulus/master' 2016-05-03 19:44:23 +02:00
Nicholas-Westby de92147ec0 WIP: Attempting to fix RTE when dragging between fieldsets (still needs some work). 2016-05-01 21:23:02 -07:00
Nicholas-Westby c2b7d2c89d Allowed rich text editors to be dragged between Archetypes. 2016-05-01 18:27:01 -07:00
Nicholas-Westby d0fe30f08b WIP: Better handling of validation errors when dragging fieldsets between Archetypes.
Added "jsonSnapshot" (utility function for troubleshooting).
Added "tolerance" (my hope is that will help drag operations act nicer with expanded fieldsets).
2016-05-01 17:33:32 -07:00
Nicholas-Westby d22ae1244e Merge remote-tracking branch 'origin/master' into feature/355-nested-dragging 2016-04-30 18:18:14 -07:00
Nicholas-Westby fa48d73630 Only allow cross-Archetype sorting of a single fieldset if it can be removed. 2016-04-28 20:32:07 -07:00
kgiszewski fb305c9d0e Fix label padding in the config 2016-04-28 11:35:05 -04:00
Nicholas-Westby be332d310f Add a top margin of 5px to empty Archetype drop zone. 2016-04-28 08:24:06 -07:00
kjac d97bbb59dc Merge remote-tracking branch 'refs/remotes/origin/master' into allowed-member-groups 2016-04-27 21:00:11 +02:00
kjac 3702ec484b Merge remote-tracking branch 'refs/remotes/imulus/master' 2016-04-27 20:59:42 +02:00
Nicholas-Westby d8d4ec1a73 Improved terminology (fieldsets are dragged across Archetypes, not across fieldsets). 2016-04-27 08:21:16 -07:00
Nicholas-Westby 32cb89bba1 Made cross-field dragging opt-in. 2016-04-26 21:40:19 -07:00
Nicholas-Westby 863f041fc9 Fixed issue when dragging newly created fieldset between Archetypes.
Ensured that fieldset aliases are compared when judging compatibility during drag.
2016-04-26 21:14:33 -07:00
Nicholas-Westby 5a83719dfc Performance optimization via short-circuiting. 2016-04-26 05:57:08 -07:00
Nicholas-Westby 1b1940fe6a Tamed a rogue comment. 2016-04-26 05:54:56 -07:00
kgiszewski b71564bfb5 Merge branch 'pr/351' 2016-04-26 07:51:50 -04:00
kgiszewski ba8a6cf65c Merge branch 'master' into pr/351 2016-04-26 07:37:33 -04:00
Nicholas-Westby 7dd07b9f9c When dragging between Archetypes, only allow the operation when a configured fieldset matches the dragged fieldset. 2016-04-25 21:05:36 -07:00
Nicholas-Westby 29652bb880 Removed a parameter I never ended up using. 2016-04-24 21:54:05 -07:00
Nicholas-Westby 62b7420eaa Prevent dragging when can't add to or remove from list of fieldsets.
Allow dragging into an empty list of fieldsets.
2016-04-24 21:38:59 -07:00
Nicholas-Westby 333f17976b Enable nested dragging. 2016-04-24 17:57:36 -07:00
kjac 45981b0431 Handle lazy load of moment.js 2016-04-23 15:30:14 +02:00
kjac 531ff0aab4 Merge remote-tracking branch 'refs/remotes/origin/fix-publishing-for-collapsed-fieldsets' into allowed-member-groups
# Conflicts:
#	app/views/archetype.default.html
2016-04-23 15:25:33 +02:00
kjac 394572a8fc Yet another stab at fixing it
By tracking the fieldsets that have been expanded (loaded), we can make
sure the submit watchers fire appropriately, even when the fieldsets are
collapsed down again.

Apart from hopefully fixing the publishing issues for collapsed
fieldsets, this also adds a performance gain if the users expand and
collapse the same fieldsets more than once, since the fieldsets now only
load the first time they're expanded (instead of every time).

This also - at least partially - fixes the validation issue #325
introduced by #301
2016-04-23 10:14:56 +02:00
kgiszewski c7114b63f5 Merge branch 'master' of github.com:imulus/Archetype 2016-04-18 11:02:10 -04:00
kgiszewski 9704a8b591 Merge branch 'pr/345' 2016-04-18 11:02:00 -04:00
kjac 0b6af3b4e1 Another stab at fixing publishing for collapsed fieldsets
Make sure we've loaded moment.js before attempting to use it.

Also a small update to styles to accommodate 7.4
2016-04-10 19:23:31 +02:00
kjac 4b874dc5b5 Another stab at fixing publishing for collapsed fieldsets 2016-04-06 20:40:29 +02:00
Kevin Giszewski a081d97546 Update README.md 2016-04-06 09:31:13 -04:00
kjac ebf3fd1135 Clean up duplicate code after merge 2016-04-04 21:32:24 +02:00
kjac 85157612f4 Merge remote-tracking branch 'refs/remotes/origin/fix-publishing-for-collapsed-fieldsets' into allowed-member-groups 2016-04-04 21:31:38 +02:00
kjac 6b79a508bb Fix publishing when all fieldsets are collapsed
Because of the lazy loading of property editors, the
submitWatcherOnSubmit method is not necessarily called when an Archetype
is saved. This is indeed the case when all fieldsets are collapsed.
2016-04-04 21:28:19 +02:00
kjac f57205dab9 More member groups implementation 2016-04-04 21:21:02 +02:00
kjac b6ccab10b3 Merge remote-tracking branch 'refs/remotes/imulus/master' into allowed-member-groups
# Conflicts:
#	app/less/archetype.less
2016-04-04 20:37:15 +02:00
kjac e1f67a738b Merge remote-tracking branch 'refs/remotes/imulus/master' 2016-04-04 20:34:37 +02:00
kgiszewski 4410f1bb81 Bump version to v1.13 2016-04-04 13:08:58 -04:00
kgiszewski 5c2a99987a Fix style so text won't overflow out. 2016-04-04 12:47:39 -04:00
kgiszewski 715a2bf6d5 Fixed missing dialogData from enablePublishing 2016-04-04 12:03:52 -04:00
kjac d9ffb4b097 Merge remote-tracking branch 'refs/remotes/origin/master' into publishing
# Conflicts:
#	app/less/archetype.less
2016-04-03 12:53:30 +02:00
kjac c409922469 Merge remote-tracking branch 'refs/remotes/imulus/master' 2016-04-03 12:43:03 +02:00
kgiszewski 6b40d1e20b Merge branch 'pr/348' 2016-04-02 19:17:51 -04:00
kgiszewski 3e91b1c2c3 Why do I have to keep committing this? 2016-04-02 19:14:30 -04:00
kgiszewski 38eafc0063 Merge branch 'pr/350' 2016-04-02 19:11:43 -04:00
kgiszewski 89aeca9bf0 Add version to json config 2016-04-02 19:11:39 -04:00
kgiszewski 2b6d87d97c Bump version to v1.12.4 2016-04-02 19:10:54 -04:00
kjac 1ca113b455 Fix issue 342 2016-03-31 23:44:52 +02:00
kjac 8228b2dae5 Scope icon styles to fieldset controls only 2016-03-31 08:17:43 +02:00
kjac 22f24ec882 Merge remote-tracking branch 'refs/remotes/imulus/master' 2016-03-31 08:02:33 +02:00
kjac e33eb863e6 #326 - support tags (and other built-in datatypes) 2016-03-29 16:01:14 +02:00
Kevin Giszewski 6bcf291c99 Update README.md 2016-03-29 09:41:05 -04:00
kjac b0f614c891 Allowed member groups PoC 2016-03-23 15:08:07 +01:00
kjac a424a7e4f3 Revert addDefaultProperties to master and adjust addCustomProperties accordingly 2016-03-23 08:38:07 +01:00
kjac 75fa2bb1bb Fix formatting 2016-03-22 19:58:48 +01:00
kjac 5585244d32 Merge remote-tracking branch 'refs/remotes/origin/master' into publishing 2016-03-22 19:40:59 +01:00
kjac 41fa8fa40d Merge remote-tracking branch 'refs/remotes/imulus/master' 2016-03-22 19:38:10 +01:00
kjac 9336f4508a Handle publishing in UTC 2016-03-22 19:35:40 +01:00
kgiszewski f9e5012b4e Merge branch 'master' into pr/338 2016-03-22 11:59:44 -04:00
kgiszewski 61d215e16c Merge branch 'master' of github.com:imulus/Archetype 2016-03-22 11:53:21 -04:00
kgiszewski e1e34be10d Merge branch 'master' into pr/311 2016-03-22 11:36:37 -04:00
Kevin Giszewski 796be76d94 Merge pull request #339 from imulus/feature/74-style
Update style for 7.4
2016-03-21 14:57:49 -04:00
kjac 8f7024c32a Comments 2016-03-20 14:05:31 +01:00
kjac dea307ff8e Filter out fieldsets based on publishing 2016-03-20 13:51:14 +01:00
kjac d69a10de48 Clean up 2016-03-20 13:37:34 +01:00
kjac b93df7a4c0 Add custom properties to new fieldsets 2016-03-20 13:28:22 +01:00
kjac 48dbdebec5 Create expandable settings group and fix icon activation 2016-03-20 13:21:43 +01:00
kjac 65837fa74c Undo a few things 2016-03-20 12:08:23 +01:00
kjac 29a73336e3 Merge remote-tracking branch 'refs/remotes/imulus/master' into publishing 2016-03-20 12:04:52 +01:00
kjac 0dfa8edc95 Merge remote-tracking branch 'refs/remotes/imulus/master' 2016-03-20 12:03:54 +01:00
kjac 0584c4eda5 Prototype (work in progress) 2016-03-20 12:02:21 +01:00
kgiszewski 4eb901fbba Fix #318 2016-03-15 10:04:59 -04:00
Greg Fyans b7875dd850 Added native label for RJP.MultiUrlPicker data type 2016-03-15 10:28:14 +00:00
Kevin Giszewski 19989e556e Update README.md 2016-03-10 12:10:30 -05:00
Kevin Giszewski 9250d66953 Update README.md 2016-03-10 12:07:53 -05:00
kgiszewski fa0b1a4b3b Add a ref required 2016-03-10 11:27:44 -05:00
kgiszewski 73e875e67c Merge branch 'master' into pr/330 2016-03-10 11:19:05 -05:00
kgiszewski e061311689 Add overloads for single partial render and cleanup stuffs 2016-03-10 11:16:27 -05:00
kjac b36f83eaf6 Merge remote-tracking branch 'refs/remotes/imulus/master' 2016-03-05 21:14:47 +01:00
Jamie Gilbert d63f7a6a34 updated angular controller to find view when umbraco is in virtual directory (using relative path) 2016-02-24 17:00:32 +00:00
leekelleher 68c2f55111 Added support to ArchetypePublishedContent for Umbraco extension methods
For the `IPublishedContent` implementation, added support for `GetIndex()`, so that extension methods, such as `IsFirst()`, `IsLast()`, etc will work as expected.

Unfortunately we wont be able to support the `Siblings()`, (or `FollowingSibling`, `PrecedingSibling`) extension methods, as these perform an internal query to the node's parent's children - which in the context of Archetype data is not possible access.

Added unit-tests to support this enhancement.
2016-02-17 13:30:43 +00:00
Jamie Gilbert f22d3cdef3 Modified HTML helper to allow you to render a single fieldset from an Archtype model.
(I Needed to render the first review in a list of review blocks)
2016-02-05 14:33:02 +00:00
kgiszewski 13b59d0d61 Bump version to v1.12.3 2016-02-04 11:20:44 -05:00
kjac 188c09d3c1 Fix issue #323
Made the config dialogs do "live editing" instead of working on a copy
of the config model.
2016-01-23 14:56:28 +01:00
kjac 6d8770907c Fix path to courier project
The gruntfile had a wrong path to the Courier project, which messed up
the grunt setup.
2016-01-23 14:55:11 +01:00
kjac efbed9606d Merge remote-tracking branch 'refs/remotes/imulus/master' 2016-01-23 10:31:06 +01:00
leekelleher c862ecc36f Fixes #319 - Grunt/MSBuild
Sets the MSBuild project config from "Debug" to "Release".
2016-01-13 12:26:19 +00:00
bjarnef 523630416f Correct for attribute to match id of input
... futhermore add title tooltip with value of property alias like in
Umbraco core.
2016-01-05 22:19:08 +01:00
kgiszewski 990836bc37 Fix #315 2016-01-05 08:39:09 -05:00
kgiszewski bb194fff76 Fix #314 2016-01-05 08:35:35 -05:00
kgiszewski 16351df692 Fix #312 2016-01-04 15:02:02 -05:00
kgiszewski 213d3940ca Merge branch 'pr/310' 2015-12-15 11:26:52 -05:00
kgiszewski 8dfe1f3ca4 Keepin it DRY 2015-12-15 11:26:40 -05:00
kgiszewski 3291998171 Merge branch 'master' into pr/308 2015-12-15 11:04:18 -05:00
kgiszewski e640a9b4f4 This depends on a core PR. 2015-12-14 09:53:01 -05:00
Martin Abrahams 7df4d4cfcd Fix for issue #258, same issue as fileupload datatype, need to add empty validation property 2015-12-10 16:03:14 +11:00
kgiszewski bb056a01dd Update dll to v1.12.1 2015-12-03 08:44:40 -05:00
kgiszewski 608b12aa10 Revert "Fix #304"
This reverts commit f4e449f030.

Conflicts:
	app/Umbraco/Umbraco.Archetype/Models/ArchetypeModel.cs
2015-12-03 08:43:23 -05:00
kjac 6494327c77 Merge remote-tracking branch 'refs/remotes/imulus/master' 2015-11-29 17:04:39 +01:00
Tom Fulton 293aa7f6f3 Update grunt-umbraco-package to v1.0 2015-11-24 21:54:01 -08:00
kgiszewski 7e76e98c0f Bump version to 1.12.0 2015-11-16 13:25:54 -05:00
kgiszewski f4e449f030 Fix #304 2015-11-16 13:24:36 -05:00
kgiszewski 1e97caa7e8 Merge branch 'pr/303' 2015-11-16 12:50:11 -05:00
leekelleher b0dcefaf06 Refactored the PublishedContent/Property classes.
Streamlines how the properties are stored and retrieved internally, (dictionary is faster than linq loops).
Removed the `Initialize` method, as we can do the set-up within the constructor.
2015-11-05 11:58:45 +00:00
kgiszewski 716972bc17 Merge branch 'pr/301' 2015-11-04 15:34:11 -05:00
leekelleher 4d4eab39e8 ArchetypeModel to IPublishedContent
Adds extension methods for `ArchetypeModel` and `ArchetypeFieldsetModel` for converting to Umbraco's `IPublishedContent`.
Included unit-tests to support the deserialization and verify property-value retrieval.

Modifies `ArchetypePropertyModelExtensions.CreateDummyPropertyType` extension method, to test if the `PropertyValueConvertersResolver` is available, (otherwise the unit-tests throw an exception from Umbraco's `PublishedPropertyType`).
2015-11-04 15:43:39 +00:00
kgiszewski 6acaf65ec3 Add missing XML docs. 2015-11-02 11:35:37 -05:00
kgiszewski a2b2567350 Fix unit tests. 2015-11-02 10:55:02 -05:00
Mark f5f4e80800 Added "lazy loading" for fieldset properties
I've had a big performance problem when loading big child archetypes in
an archetype, by adding a ng-if the digest cycle isn't called directly
when loading the directive
2015-10-26 10:52:27 +01:00
Mark b42695bd0d Merge remote-tracking branch 'imulus/master' 2015-10-26 10:46:19 +01:00
kgiszewski f405239115 Fixed goofed up packages, bump to v1.11.1 2015-10-08 13:42:19 -04:00
kgiszewski 4be6a13fc0 This never got bumped up, but most people are past that version. 2015-10-08 09:00:19 -04:00
kgiszewski 99638ed0b0 Add missing twitter style 2015-10-08 08:49:22 -04:00
kgiszewski fd28df1bad Update Gruntfile to remove versioning files 2015-10-08 08:43:08 -04:00
kgiszewski 165a98c89e Add Twitter link 2015-10-08 08:07:35 -04:00
kgiszewski ca1214a09a Remove FieldsetToolbar option as it was only for the prototype. Tweak Gruntfile 2015-10-08 07:52:30 -04:00
Kenn Jacobsen 17062c6913 Subdivide fieldset options in dialog + use dialog footers in all dialogs 2015-10-08 08:56:48 +02:00
Kenn Jacobsen 16e73446fd Merge remote-tracking branch 'imulus/feature/options-ui' into feature/options-ui 2015-10-08 08:17:05 +02:00
Kenn Jacobsen e56356534e Merge remote-tracking branch 'imulus/master' 2015-10-08 08:13:09 +02:00
kgiszewski 21b933a0dc Version HTML 2015-10-07 17:34:35 -04:00
kgiszewski e3a2b66022 Version css and js files 2015-10-07 17:11:26 -04:00
kgiszewski 645198444b Add dll version to the config page 2015-10-07 16:28:00 -04:00
kgiszewski 0e9bef9048 Add logo asset, add headlines to dialogs 2015-10-07 16:11:15 -04:00
kgiszewski bd4398ff28 Bump version to 1.11 and some minor edits 2015-10-07 15:42:00 -04:00
kgiszewski a4f371a4ca Enforce one dialog at a time. 2015-10-07 15:34:30 -04:00
kgiszewski e465861da6 Add cancel/apply buttons 2015-10-07 13:57:49 -04:00
kgiszewski 3fdfa2b2c6 Removed the 'name' label as it takes up a fair bit of space and is sort of redundant 2015-10-07 13:19:24 -04:00
kgiszewski 9787af9ed6 Fixup some styles and move some controller functions for the grouping 2015-10-07 13:13:56 -04:00
kgiszewski b8fc0fb71c WIP 2015-10-07 12:20:09 -04:00
kgiszewski de7ed9328d Merge branch 'pr/296' 2015-10-07 09:32:46 -04:00
Kenn Jacobsen ee8b16eb9b Only show fieldset groups config when "multiple fieldsets" is enabled 2015-10-05 15:03:08 +02:00
Kenn Jacobsen 5465c1c899 Use exact match on group name 2015-10-05 14:37:11 +02:00
kgiszewski 3402f216b9 Add more verbose error logging 2015-10-05 08:13:50 -04:00
Kenn Jacobsen 490de7b3ff Move fieldset groups config to advanced settings 2015-10-05 09:42:31 +02:00
kjac 275b5d2207 Introduce fieldset groups 2015-10-04 21:39:50 +02:00
Kenn Jacobsen bc19e6dda1 Merge branch 'master' into fix-194-again 2015-10-02 13:42:50 +02:00
Kenn Jacobsen 3904b6527e Fix editor dragging once again 2015-10-02 13:40:09 +02:00
Tom Fulton d5fd59b954 Remove editorState from model before persisting 2015-09-28 23:26:07 -06:00
kgiszewski e01c50f08a Fix #289 2015-09-02 09:46:22 -04:00
kgiszewski 1e9c7d0a6c Final tweaks to css and version numbers 2015-08-25 12:59:26 -04:00
Kevin Giszewski 3cf153fc80 Merge pull request #286 from kjac/ui-overhaul
UI overhaul
2015-08-25 08:54:26 -04:00
Kenn Jacobsen 8e11a33031 Make sure fieldset names are not cropped 2015-08-19 15:22:53 +02:00
kgiszewski 5c95f59219 Bump version number 2015-08-19 09:04:41 -04:00
kgiszewski 01b59f28f1 Merge branch 'pr/287' into rc/ui-1 2015-08-19 08:33:54 -04:00
Mark f40e023420 Changed the way tags are stripped from tinymce content
See stackoverflow for a reference
2015-08-19 13:02:55 +02:00
Kenn Jacobsen 6d9c32e30d Localization 2015-08-19 12:40:44 +02:00
Kenn Jacobsen 2f48e9da9a Merge branch 'master' into ui-overhaul 2015-08-19 12:19:54 +02:00
Kenn Jacobsen 2aa71e48a3 Prettify the "default add" button a little 2015-08-19 11:57:39 +02:00
Kenn Jacobsen e6732d2a37 Close fieldtype picker when clicked outside it 2015-08-19 11:57:13 +02:00
Kenn Jacobsen a7dca93781 Moved some CSS hover rules to a more appropriate target 2015-08-19 07:35:41 +02:00
kjac 0ec0e213a2 Make the delete icon red on hover 2015-08-18 23:11:44 +02:00
kjac 6919c5a8b4 A bit more styling of carets + make empty headers clickable 2015-08-18 23:09:40 +02:00
kjac 6505323297 Removed obsolete dropdown toggles 2015-08-18 19:03:36 +02:00
kgiszewski ec8df1d465 Housekeeping 2015-08-18 13:03:11 -04:00
kjac 451f2773a4 Add fieldtype picker
...and removed old dropdowns. Plus a bit more styling.
2015-08-18 17:59:20 +02:00
Kenn Jacobsen f366305583 Overhaul WIP 2015-08-18 15:10:37 +02:00
kgiszewski 43a72ed5e5 Use relative paths instead of tilde due to core compatibility issues 2015-08-17 12:16:38 -04:00
kgiszewski 709198f943 Merge branch 'master' of github.com:imulus/Archetype 2015-08-17 11:53:44 -04:00
Kevin Giszewski 77f72ed72e Merge pull request #283 from kipusoep/master
Fixes for Virtual Directories #156
2015-08-17 11:47:52 -04:00
kgiszewski a03fe3af32 Remove some cruft 2015-08-17 11:47:08 -04:00
Stefan Kip 697a797c7e Fixes for Virtual Directories #156 2015-08-14 14:49:41 +02:00
kgiszewski cfe014ee45 Bump version number 2015-07-08 13:26:06 -04:00
kgiszewski d62fa05ab5 Handle 7.2.6 issue 2015-07-01 09:25:18 -04:00
kjac 662cf4c3bf More formatting 2015-06-26 14:17:52 +02:00
kjac d0b8314134 Formatting issue 2015-06-26 14:09:12 +02:00
kjac 8eb4786976 Revert API method GetByGuid() to its previous state
All default prevalue enrichment is now handled by the API method
GetAllPropertyEditors()
2015-06-26 14:08:00 +02:00
kjac 20155b5ca6 Move filenames collection to temporary editor state container 2015-06-26 11:30:51 +02:00
kjac 16c310f3c6 Ensure correct default prevalues for imagecropper 2015-06-26 11:27:54 +02:00
kjac 99d570dc97 Handle upload and image cropper clientside 2015-06-25 07:59:16 +02:00
kjac 2ae3e3ade9 Merge with imulus/master 2015-06-23 17:21:26 +02:00
Kevin Giszewski d4718e358c Merge pull request #279 from leekelleher/enhancement/helper-log-exception
ArchetypeHelper - added exception to Umbraco log
2015-06-18 08:05:10 -04:00
Kevin Giszewski bb91eb7036 Merge pull request #280 from leekelleher/upgrade/courier-assemblies
Upgraded Courier assemblies.
2015-06-18 08:03:58 -04:00
leekelleher 484f2c22a3 Added exception to Umbraco log, as VS was complaining about an unused ex. 2015-06-18 12:20:02 +01:00
leekelleher a2121cd8a7 Upgraded Courier assemblies.
Amended references to Courier constants (seems that there was some restructuring within Courier)
2015-06-18 12:17:44 +01:00
kgiszewski 2fb922fd6c Rework dropdown label to check for a value first 2015-06-15 15:56:45 -04:00
kgiszewski c2986d39a9 Added coreDropdown to label helpers 2015-06-15 15:46:51 -04:00
kgiszewski 8ee5488261 Merge branch 'master' of github.com:imulus/Archetype 2015-06-15 14:49:19 -04:00
kgiszewski c60c9e1c5d Fix #276 2015-06-15 14:48:50 -04:00
kgiszewski 8610f69c88 Bump version to v1.8 2015-06-04 13:26:19 -04:00
kgiszewski 34b4209de7 For some reason sorting the RTE reared its head again and I killed it (again). 2015-06-02 10:49:47 -04:00
Kevin Giszewski b6145c9275 Merge pull request #275 from imulus/feature/label-library
Allow args to be passed to label templates and begin label library
2015-06-01 13:54:43 -04:00
kgiszewski f51ca65659 Expose archetypePropertyEditorResource to controller 2015-06-01 13:53:18 -04:00
kgiszewski d026af9fd2 Expose archetypeCacheService on controller 2015-06-01 13:49:34 -04:00
kgiszewski 11fff5da1a Add media picker support 2015-06-01 13:43:42 -04:00
kgiszewski 788a5dd720 Wire up MNTP 2015-06-01 13:35:53 -04:00
kgiszewski 24e232b2cc Renaming binge 2015-06-01 12:12:33 -04:00
kgiszewski 5bdcb23933 Cache datatypes as they come back from server 2015-06-01 11:16:12 -04:00
kgiszewski 34b3ed3b47 Add archetypeCacheService 2015-06-01 10:13:29 -04:00
kgiszewski 50a486a9ac Discovered we should probably use a datatype cache based on the directive, so maybe a archetypeCacheService? 2015-06-01 10:09:22 -04:00
kgiszewski 4f4128a744 Fix some broken-ness 2015-06-01 10:02:32 -04:00
kgiszewski 4851797a83 Refactor a ton of things, add archetypeLabelService 2015-06-01 09:45:10 -04:00
kgiszewski 54a435dce7 Begin archetypeService 2015-05-29 08:55:08 -04:00
kgiszewski 03a170d716 Add RTE label template 2015-05-27 13:56:33 -04:00
kgiszewski 37976abc84 Handle arg detection better and change UrlPicker functionname 2015-05-27 13:47:23 -04:00
kgiszewski f7e96438be Handle null ref 2015-05-27 13:41:58 -04:00
kgiszewski f1c3caae2d Allow args to be passed to label templates and begin label library 2015-05-27 13:31:25 -04:00
kgiszewski 8f8078e12f Merge branch 'master' into pr/272 2015-05-26 08:33:34 -04:00
kgiszewski dbc9b872d8 Fix #274 2015-05-26 08:28:32 -04:00
Nicholas-Westby eef1b94586 Hide long fieldset headers with an ellipsis before overlapping buttons: https://github.com/imulus/Archetype/issues/271 2015-05-23 00:01:25 -07:00
kgiszewski 9bbf366fe2 Bump version to v1.7.5 2015-05-11 15:32:46 -04:00
kgiszewski 368a9f6c07 Fix for #268 2015-05-11 15:31:46 -04:00
kgiszewski d3b3f80f3d Add Umbraco as a dependency 2015-05-11 15:20:28 -04:00
kgiszewski 11f7881dd7 Merge branch 'master' of github.com:imulus/Archetype 2015-05-04 13:46:07 -04:00
kgiszewski 9894357469 Fix #268 (This is a temp fix until a better solution can be found) 2015-05-04 13:45:49 -04:00
kgiszewski 146a3770a1 Bump version to v1.7.4 2015-05-03 16:41:41 -04:00
kgiszewski caf9d1ac15 Fix grunt for debug 2015-04-29 08:53:18 -04:00
kgiszewski 614595ceb3 Finesse PR #269 2015-04-29 08:53:05 -04:00
kgiszewski d1b21a1ca7 Merge branch 'pr/269' 2015-04-29 08:13:40 -04:00
kgiszewski 54bc507049 Merge branch 'pr/267' 2015-04-29 08:12:56 -04:00
kgiszewski 037585458c Merge branch 'pr/266' 2015-04-29 08:12:15 -04:00
kgiszewski f52649eb9e Add Courier to the build process for distro 2015-04-29 08:08:08 -04:00
kgiszewski 423fedb954 Undo add Courier to distro per @leekelleher 's suggestion that it causes a ysod if Courier is not installed already 2015-04-29 07:46:37 -04:00
Kim Pilgaard b39312ccd2 Properties which no longer exist have no GUID. Remove these when reading and writing the data. 2015-04-29 08:56:17 +02:00
Gavin Faux b9c4be0bb6 PropertyEditorAlias null check
Don't try `PropertyValueConverters` for properties with null or empty
`PropertyEditorAlias`, prevents `System.NullReferenceException`  in
`PropertyValueConverter.IsConverter` implementations
2015-04-28 14:30:08 +01:00
Tom Van Rompaey 29285607a9 Small UX update for add button
Added class "archetypeAddButton" to the button so it can make use of the
CSS that is writen for it.
The button should also have a cursor: pointer on hover.
2015-04-25 16:16:04 +02:00
kgiszewski 909b87cea0 Add Courier dll to the distribution 2015-04-21 08:43:44 -04:00
kgiszewski 3d25f75fb9 Bump version number to v1.7.3 2015-04-16 08:54:36 -04:00
kgiszewski 6fa713f88e Change to the internal event 2015-04-15 15:32:08 -04:00
kgiszewski d9982fe3a2 Merge branch 'master' of github.com:imulus/Archetype 2015-04-15 15:30:11 -04:00
kgiszewski 588bdfe429 Update to Tom's latest packager 2015-04-15 15:30:03 -04:00
Kevin Giszewski 0174f6d78b Merge pull request #262 from kjac/submit-watcher
Fix #261
2015-04-15 15:29:33 -04:00
Kevin Giszewski 84144b6206 Update Readme 2015-04-10 11:27:11 -04:00
kjac 27910e8d22 Fix #261
Add a watch to the "formSubmitting" event for each property added to a
fieldset, to make sure Archetype gets the last say in the
"formSubmitting" event.
2015-04-04 21:57:49 +02:00
Tom Fulton 9bf413207f Fix logic issue with assemblyinfo patcher 2015-04-02 23:24:54 -06:00
kgiszewski e5cd3d0cb0 Bump Version to 1.7.2 2015-03-31 11:04:57 -04:00
leekelleher 032ee958c1 Minor whitespace formatting 2015-03-27 15:48:14 +00:00
Kevin Giszewski ef5bd7ccc8 Merge pull request #259 from sitereactor/master
Updates the Courier provider
2015-03-24 13:51:47 -04:00
Morten Christensen 7839e4a992 Updates the Courier provider to only use Courier code instead of relying on PropertyEditorConverters 2015-03-24 16:11:19 +01:00
kgiszewski 408c178348 Fix #194 2015-03-13 10:18:57 -04:00
kgiszewski 852b7a92a7 Update for v7.2.2 locale issue 2015-02-26 10:37:27 -05:00
kgiszewski 5a4118a1cc Bump version and fix clone issue 2015-01-27 11:05:43 -05:00
kgiszewski 4b603bf97f Bump Version Number 2015-01-27 10:53:17 -05:00
kgiszewski c8884c8d92 Add Cloning 2015-01-27 10:51:22 -05:00
kgiszewski dd843ce2c6 Make deep requests not the default 2015-01-27 10:01:59 -05:00
kgiszewski 8036ab72d0 Merge branch 'alt-label-template' 2015-01-27 09:44:36 -05:00
kgiszewski b25d8bdc4b Merge branch 'fix/datatype-caching' 2015-01-27 09:42:36 -05:00
Nicholas-Westby 023d99cc88 Improved performance of publish operations: https://github.com/imulus/Archetype/issues/238 2015-01-26 12:59:19 -08:00
kjac 1cc0586c75 Support alternative property in label template
Allow fieldset label templates to contain alternative/fallback property
aliases and/or functions by seperating with "|" - e.g.
{{title|myFunction(text)}}
2015-01-10 11:16:00 +01:00
kjac a16b61f03f Merge remote-tracking branch 'upstream/master' 2015-01-10 08:26:41 +01:00
Tom Fulton 7ea01cad86 Remove caching for property datatype dropdowns 2014-12-03 21:46:13 -07:00
Mads Krohn aea65a531d Tweak dropdown position for new fields
See related issue
2014-11-02 12:56:12 +01:00
Kevin Giszewski 482cb5a149 beta = gtfo 2014-11-02 12:56:12 +01:00
Kevin Giszewski 81ac5fbddb Update lang files 2014-11-02 12:56:11 +01:00
Kevin Giszewski 801baf355b Bump version number to v1.6 2014-11-02 12:56:10 +01:00
Kevin Giszewski a3b531caa4 Tidy up the PR 2014-11-02 12:56:10 +01:00
doronuziel71 1d680c612e Fixed type-o 2014-11-02 12:56:09 +01:00
doronuziel71 cdea3c1aec Fixed type-o 2014-11-02 12:56:09 +01:00
doronuziel71 37fa9c40d6 Introduced override default propety converter 2014-11-02 12:56:08 +01:00
Kevin Giszewski 774ba46e13 Flip-flop scope and fieldset 2014-11-02 12:56:07 +01:00
Kevin Giszewski 280a97c8d1 Expose FS (fieldsets) and Property (alias/value) for helping with creating Archetype from code 2014-11-02 12:56:07 +01:00
Kevin Giszewski 7dd3848bdf Expose serializer for those wanting to create Archetypes from code 2014-11-02 12:56:06 +01:00
leekelleher add44e533a Courier: Turns out that creating a new instance of PropertyItemProvider was a hack.
Replaced with getting the item-provider from the existing collection.
2014-11-02 12:56:05 +01:00
leekelleher 870b848e3b Bug fix with the Courier resolver 2014-11-02 12:56:05 +01:00
leekelleher b262d8a86f Set the project's assembly references to not "Copy Local".
As these pollute the /bin output folder during build.
2014-11-02 12:56:04 +01:00
leekelleher 5dba1a0895 Fixed the type-name for the error log messages 2014-11-02 12:56:03 +01:00
leekelleher 8f4857aba1 Fixed issue with Courier serialization.
When Courier was deserializing, it was treating any nested Archetype as a `JObject`.
The newer serializer routines in Archetype core resolve the previous issue.
2014-11-02 12:56:03 +01:00
leekelleher cd95404a08 PersistenceManager.Default was obsoleted, replaced calls with ExecutionContext.DatabasePersistence 2014-11-02 12:56:02 +01:00
leekelleher 7e7a4aff58 Upgraded Courier assemblies. 2014-11-02 12:56:01 +01:00
Mads Krohn c9d8952b7f Tweak dropdown position for new fields
See related issue
2014-10-02 14:46:26 +02:00
Kevin Giszewski 890b5674a6 beta = gtfo 2014-09-26 09:27:31 -04:00
Kevin Giszewski 7f5dbd31c9 Update lang files 2014-09-26 09:13:31 -04:00
Kevin Giszewski a2255aa037 Bump version number to v1.6 2014-09-25 14:27:52 -04:00
Kevin Giszewski 415a84f5c0 Tidy up the PR 2014-09-25 14:21:16 -04:00
doronuziel71 3a0eba401a Fixed type-o 2014-09-17 19:18:47 +03:00
doronuziel71 991d56dac1 Fixed type-o 2014-09-17 19:17:58 +03:00
doronuziel71 f704088bcb Merge remote-tracking branch 'upstream/master' 2014-09-17 18:37:00 +03:00
doronuziel71 a599215620 Introduced override default propety converter 2014-09-16 23:32:16 +03:00
Kevin Giszewski a6e76cb398 Flip-flop scope and fieldset 2014-09-16 13:55:54 -04:00
Kevin Giszewski 4fd134ac74 Expose FS (fieldsets) and Property (alias/value) for helping with creating Archetype from code 2014-09-08 10:39:13 -04:00
Kevin Giszewski 22b87c0a37 Merge branch 'develop' of github.com:imulus/Archetype into develop 2014-09-08 10:00:28 -04:00
Kevin Giszewski d707b55362 Expose serializer for those wanting to create Archetypes from code 2014-09-08 10:00:05 -04:00
Kevin Giszewski 37a195109c Merge pull request #220 from leekelleher/feature/courier-upgrade
Courier: Fix for PropertyItemProvider reference
2014-09-04 08:52:10 -04:00
leekelleher 205919ccae Courier: Turns out that creating a new instance of PropertyItemProvider was a hack.
Replaced with getting the item-provider from the existing collection.
2014-09-04 11:05:41 +01:00
leekelleher 04e57b7d6b Bug fix with the Courier resolver 2014-09-02 16:52:41 +01:00
Kevin Giszewski 9e8cc0c556 Merge pull request #218 from leekelleher/feature/courier-upgrade
Bug fix with the Courier resolver
2014-09-02 11:52:27 -04:00
Kevin Giszewski 8fe90c3b86 Merge pull request #216 from leekelleher/feature/courier-upgrade
Courier upgrade (UaaS)
2014-09-02 08:58:20 -04:00
Kevin Giszewski 99581b0aeb Merge pull request #217 from leekelleher/develop
Housekeeping
2014-09-02 08:57:35 -04:00
leekelleher d8939c59a0 Set the project's assembly references to not "Copy Local".
As these pollute the /bin output folder during build.
2014-09-02 13:30:21 +01:00
leekelleher e49fe6ee17 Fixed the type-name for the error log messages 2014-09-02 13:27:29 +01:00
leekelleher ca52f0a216 Fixed issue with Courier serialization.
When Courier was deserializing, it was treating any nested Archetype as a `JObject`.
The newer serializer routines in Archetype core resolve the previous issue.
2014-09-02 13:24:40 +01:00
leekelleher 08d4e4b51d PersistenceManager.Default was obsoleted, replaced calls with ExecutionContext.DatabasePersistence 2014-09-02 13:20:29 +01:00
leekelleher e9c51ee96e Upgraded Courier assemblies. 2014-09-02 13:20:15 +01:00
Kevin Giszewski b5f281cae0 Prefix property aliases to avoid core css conflicts (BREAKING) 2014-08-26 10:43:37 -04:00
Kevin Giszewski 3bbb27f85e Fix error state LESS and other stuffs 2014-08-26 10:43:13 -04:00
Kevin Giszewski 247eea3477 Merge branch 'develop' 2014-08-26 10:05:18 -04:00
Kevin Giszewski 8635fa7301 Cleanup the LESS even if a little 2014-08-26 10:05:02 -04:00
Rasmus John Pedersen e49a8d947d fixed bug with custom view 2014-08-22 10:46:45 +02:00
Kevin Giszewski 3e2e43d342 Update langs and bump version number 2014-08-21 13:00:52 -04:00
Jeavon Leopold 78ba99a52e Change Archetype value conversion attempt to pass in the Source value to ConvertSourceToObject instead of the Data value 2014-08-18 17:14:17 +01:00
Kevin Giszewski 42efa1a3d4 Merge branch 'pr/200'
Conflicts:
	app/directives/archetypeproperty.js
2014-08-18 09:43:06 -04:00
Kevin Giszewski d2f4fce808 Add enable deep requests 2014-08-18 08:55:13 -04:00
Kevin Giszewski d76a5f58d4 Merge branch 'develop' 2014-08-13 11:29:12 -04:00
Kevin Giszewski f6457416cc Make sort icon black
- WS cleanup
2014-08-13 11:28:57 -04:00
Kevin Giszewski c841813a74 decouple entityResource from the function call 2014-08-13 11:15:29 -04:00
Kevin Giszewski bcc7be94e7 fix typo 2014-08-13 11:05:27 -04:00
Kevin Giszewski e200c22244 More caching 2014-08-12 19:15:08 -04:00
Kevin Giszewski 244db7f19d Add caching to $http.gets 2014-08-12 19:04:20 -04:00
Kevin Giszewski 31f3d00b76 Add label helpers 2014-08-12 17:15:16 -04:00
Kevin Giszewski 07125bae84 Add ability to pass function as template 2014-08-12 16:56:23 -04:00
kjac f2a8286f00 Fix #131 again
Simplified the validation and fixed the problem mentioned in #131 with
only the last field in a fieldset being validated.
2014-08-11 19:12:38 +02:00
Kevin Giszewski 5725c0770e Bump version number to v1.4.1 2014-08-06 09:22:08 -04:00
Kevin Giszewski 210fbb8230 Fix for #158 2014-08-06 09:20:17 -04:00
Kevin Giszewski c8e398c726 Merge pull request #195 from imulus/feature/fix193
Fix for #193
2014-08-06 08:55:47 -04:00
Kevin Giszewski bfa882fa01 Fix for #193 2014-08-06 08:55:10 -04:00
Kevin Giszewski 876aea4007 Merge branch 'pr/186' into develop 2014-08-06 08:45:55 -04:00
Jeroen Breuer 07750c7537 Run ConvertDataToSource before ConvertSourceToObject 2014-08-05 13:17:34 +02:00
Kevin Giszewski 17a1577d09 Merge branch 'master' of github.com:imulus/Archetype 2014-07-31 13:55:07 -04:00
Kevin Giszewski 987f383139 Merge pull request #184 from imulus/fix/class-conflicts
Prefix fieldset class names to help avoid conflicts
2014-07-31 13:54:58 -04:00
Kevin Giszewski dc14f11f83 Merge pull request #191 from jbreuer/patch-5
Fix 4 for #187
2014-07-31 13:54:48 -04:00
Kevin Giszewski 500f4c4dee Merge pull request #190 from jbreuer/patch-4
Fix 3 for #187
2014-07-31 13:53:41 -04:00
Kevin Giszewski a16451df1f Merge pull request #189 from jbreuer/patch-3
Fix 2 for #187
2014-07-31 13:53:34 -04:00
Kevin Giszewski 9ac7877174 Merge pull request #188 from jbreuer/patch-2
Fix 1 for #187
2014-07-31 13:53:10 -04:00
Kevin Giszewski 4d3bcb68b3 Merge branch 'pr/188' into develop 2014-07-31 13:44:43 -04:00
Kevin Giszewski 30074fe198 Merge branch 'pr/191' into pr/188 2014-07-31 13:37:01 -04:00
Kevin Giszewski 7f0bd45a9d Merge branch 'pr/190' into pr/188 2014-07-31 13:36:59 -04:00
Kevin Giszewski 6045eed5c5 Merge branch 'pr/189' into pr/188 2014-07-31 13:36:55 -04:00
Jeroen Breuer 57ffa69ff5 Added node id 2014-07-31 12:12:35 +02:00
Jeroen Breuer 6b61dc978a Added node id 2014-07-31 12:11:51 +02:00
Jeroen Breuer c20aa64af2 Added node id 2014-07-31 12:11:02 +02:00
Jeroen Breuer 25826958a3 Fix 4 for #187 2014-07-30 16:34:33 +02:00
Jeroen Breuer b5bfbb5c25 Fix 3 for #187 2014-07-30 16:33:01 +02:00
Jeroen Breuer 9afaa024c0 Fix 2 for #187 2014-07-30 16:30:42 +02:00
Jeroen Breuer c58dcd80ff Fix 1 for #187 2014-07-30 16:26:42 +02:00
Jeroen Breuer b7c16ee6ef Fix for #185 2014-07-29 16:24:14 +02:00
tomfulton 786c547e0b Prefix fieldset class names to help avoid conflicts 2014-07-24 06:35:33 -06:00
Kevin Giszewski fbf686f559 Bump Version Number to v1.4.0 2014-07-11 10:38:08 -04:00
Kevin Giszewski 42b4076700 Merge branch 'pr/174' 2014-07-11 10:19:00 -04:00
Kevin Giszewski 5feb415093 Update some dropdown css 2014-07-11 10:17:49 -04:00
Kevin Giszewski 79c85cf86b Merge branch 'master' into pr/174 2014-07-09 16:42:18 -04:00
Kevin Giszewski a0f65370c9 Few CSS tweaks 2014-07-09 16:40:29 -04:00
Kevin Giszewski 029d17c428 Merge branch 'master' of github.com:imulus/Archetype 2014-07-09 15:46:17 -04:00
Kevin Giszewski e262d7b0c9 Re-fix the 'hide label' issue
- appears to have been undone
2014-07-09 15:46:05 -04:00
kjac 44ea6c56f5 Use propertyAlias in fieldset validation
As described in #162 the umbracoPropertyAlias has been removed in favor
of a more unique propertyAlias. This propertyAlias should be used for
property identification in the validation.
2014-07-01 22:28:20 +02:00
leekelleher d7477eaf6d Moved the ArchetypePropertyModel.CreateDummyPropertyType to an extension method.
With a view to re-use in the Courier DataResolver (as it does the same function).
2014-07-01 21:46:25 +02:00
leekelleher c33649201f Separated out the extension methods into their own grouped classes.
Implements #172
2014-07-01 21:46:25 +02:00
leekelleher 3940955360 Code tidy-up; correct method naming; removed unused references 2014-07-01 21:46:24 +02:00
leekelleher 03f66a35f7 Refactored the DataResolver, as the underlying JSON value for the property had been modified (fields removed). 2014-07-01 21:46:24 +02:00
leekelleher b4b60dd89c Add the 'Archetype.Courier' project.
Includes the Courier DataResolver for Archetype.
2014-07-01 21:46:23 +02:00
leekelleher 4105912394 Code tidy-up: removed the "Models" namespace from the type name. 2014-07-01 21:46:22 +02:00
Kevin Giszewski 7b3d31f897 Merge pull request #173 from leekelleher/feature/issues/172
Separated out the extension methods into their own grouped classes
2014-07-01 11:52:43 -04:00
leekelleher 50861badf1 Moved the ArchetypePropertyModel.CreateDummyPropertyType to an extension method.
With a view to re-use in the Courier DataResolver (as it does the same function).
2014-07-01 16:49:20 +01:00
leekelleher fa682c3717 Separated out the extension methods into their own grouped classes.
Implements #172
2014-07-01 16:48:13 +01:00
Kevin Giszewski d18d1ff0b1 Merge pull request #171 from leekelleher/feature/courier-resolver
Includes Courier DataResolver project
2014-07-01 11:27:21 -04:00
leekelleher 247491187a Code tidy-up; correct method naming; removed unused references 2014-07-01 16:09:34 +01:00
leekelleher 80194786a1 Refactored the DataResolver, as the underlying JSON value for the property had been modified (fields removed). 2014-07-01 15:42:41 +01:00
Kevin Giszewski 72ee7b3d09 Merge pull request #170 from leekelleher/master
Code tidy-up: removed the "Models" namespace from the type name.
2014-07-01 10:20:18 -04:00
leekelleher 284b1d93dc Add the 'Archetype.Courier' project.
Includes the Courier DataResolver for Archetype.
2014-07-01 14:28:02 +01:00
leekelleher 7c5a3c34e2 Code tidy-up: removed the "Models" namespace from the type name. 2014-07-01 13:54:18 +01:00
Kevin Giszewski fa970750d1 Bump version number to v.1.3.1-beta 2014-06-30 11:22:34 -04:00
Kevin Giszewski aeeb3c7b40 Remove Serialization 2014-06-30 11:22:21 -04:00
Kevin Giszewski bdd3c2088c Bump version number to v1.3.0 2014-06-30 10:48:07 -04:00
Kevin Giszewski 80b41e4a5f Fix #168 2014-06-30 10:45:48 -04:00
Kevin Giszewski d60e7ba2f4 Merge branch 'master' into pr/166 2014-06-30 10:39:59 -04:00
Kevin Giszewski 4524320db2 Merge branch 'master' into pr/166 2014-06-30 09:47:10 -04:00
kjac 90ca77c9a9 Add localization to new config item 2014-06-28 12:51:36 +02:00
kjac 8332a841eb Implement #165 - enable/disable fieldsets 2014-06-28 12:42:36 +02:00
kjac d6a13b2335 Merge remote-tracking branch 'upstream/master' 2014-06-28 11:25:59 +02:00
cankoluman 987e5cf470 Issue #AR-8_line_endings: fix build 2014-06-27 14:27:48 +01:00
cankoluman f2e5b83795 Issue #AR-8_line_endings: fix line endings so we match the upstream 2014-06-27 14:16:54 +01:00
cankoluman 066e807847 Merge remote-tracking branch 'origin/dev/AR-6_legacy_nesting' into dev/AR-8_line_endings
Conflicts:
	app/Umbraco/Archetype.Tests/Serialization/UseCases/ArchetypeJsonConverterTest.cs
	app/Umbraco/Archetype.Tests/Serialization/UseCases/Complex/ArchetypeJsonConverterTest.cs
	app/Umbraco/Archetype.Tests/Serialization/UseCases/JsonTestModels.cs
	app/Umbraco/Umbraco.Archetype/Extensions/Extensions.cs
	app/Umbraco/Umbraco.Archetype/Properties/VersionInfo.cs
	app/Umbraco/Umbraco.Archetype/Serialization/ArchetypeJsonConverter.cs
	app/Umbraco/Umbraco.Archetype/Serialization/AsArchetypeAttribute.cs
	app/Umbraco/Umbraco.Archetype/Serialization/AsFieldsetAttribute.cs
	app/Umbraco/Umbraco.Archetype/Serialization/SerializationExtensions.cs
	config/meta.json
2014-06-27 12:47:52 +01:00
cankoluman d8378ed6bb Merge remote-tracking branch 'origin/dev/AR-1_serialization' into dev/AR-8_line_endings
Conflicts:
	app/Umbraco/Archetype.Tests/Serialization/UseCases/ArchetypeJsonConverterTest.cs
	app/Umbraco/Archetype.Tests/Serialization/UseCases/Complex/ArchetypeJsonConverterTest.cs
	app/Umbraco/Archetype.Tests/Serialization/UseCases/JsonTestModels.cs
	app/Umbraco/Umbraco.Archetype/Archetype.Umbraco.csproj
	app/Umbraco/Umbraco.Archetype/Extensions/Extensions.cs
	app/Umbraco/Umbraco.Archetype/Properties/VersionInfo.cs
	app/Umbraco/Umbraco.Archetype/PropertyConverters/ArchetypeValueConverter.cs
	app/Umbraco/Umbraco.Archetype/Serialization/ArchetypeJsonConverter.cs
	app/Umbraco/Umbraco.Archetype/Serialization/AsArchetypeAttribute.cs
	app/Umbraco/Umbraco.Archetype/Serialization/AsFieldsetAttribute.cs
	app/Umbraco/Umbraco.Archetype/Serialization/SerializationExtensions.cs
2014-06-27 12:42:40 +01:00
kjac 19ee2b890c Merge remote-tracking branch 'upstream/master' 2014-06-27 06:33:15 +02:00
Kevin Giszewski c953f12412 Merge branch 'pr/157' into pr/164 2014-06-26 15:58:31 -04:00
kjac 601f2c0d81 Fix issue #162 + improve nested validation highlighting
The fieldset.isValid property isn't necessarily initialized when the
view looks for it to determine fieldset validity. I've introduced a
validation method that counters this problem.
The validation method also ensures that any validation errors in nested
Archetypes are highlighted on the parent/root Archetype
2014-06-26 14:58:55 +02:00
kjac 283dd8af76 Merge remote-tracking branch 'upstream/master' 2014-06-26 14:23:40 +02:00
Tom Fulton c83942dc5c Update field labels to match new property alias scheme
Only for the first level, since focusing an Archetype isn't really a thing
2014-06-25 22:03:22 -04:00
Tom Fulton a0ff42a84f Merge branch 'master' into fix/unique-aliases
Conflicts:
	app/views/archetype.default.html
2014-06-25 21:49:24 -04:00
Tom Fulton ed97d586b4 Make property aliases even more unique
archetype-property-<umbracoPropertyAlias>-<fieldsetIndex>-<archetypePropertyAlias>-<archetypePropertyIndex>-<and so on...>
2014-06-25 21:46:46 -04:00
Kevin Giszewski 1bd09799b4 Fix for #160 2014-06-25 18:42:41 +02:00
Kevin Giszewski 0b77ddeef1 Fix 'hide property label' 2014-06-25 18:42:40 +02:00
kjac 2b2d0b4b0d Fix code formatting 2014-06-25 18:42:39 +02:00
kjac dc992293e1 Add default value overload to GetValue()
Fix issue #142
2014-06-25 18:42:39 +02:00
kjac 0bc1451a5c Fixing the unit tests
The call to DisposableTimer.DebugDuration() in
ArchetypeValueConverter.ConvertDataToSource() expects the propertyType
parameter to be not null, but the implementation of
ArchetypeValueConverter.ConvertDataToSource() allows the propertyType
parameter to be null. This breaks some of the unit tests.
I've added a null check in the call to DisposableTimer.DebugDuration()
to counter this issue.
2014-06-25 18:42:38 +02:00
Kevin Giszewski f052ed70a9 Merge pull request #161 from imulus/feature/fix-customviews
Fix for #160
2014-06-25 10:29:22 -04:00
Kevin Giszewski 0dedd7fb2d Fix for #160 2014-06-25 10:28:30 -04:00
Kevin Giszewski cb6455c34a Merge branch 'master' into develop 2014-06-25 08:35:07 -04:00
Kevin Giszewski f99ef697db Fix 'hide property label' 2014-06-25 08:34:54 -04:00
Tom Fulton aac015dc0b Refactor property aliases for uniqueness
Old: archetype-property-<umbracoPropertyAlias>-<fieldsetIndex>-<propertyIndex>
New: archetype-property-<umbracoPropertyAlias>-<archetypePropertyAlias>-<fieldsetIndex>

Basically, this adds the archetypePropertyAlias into the mix, to fix a case where you might have the same Archetype nested on a host Archetype twice  (ie box 1 links, box 2 links within the same Archetype - there was no uniqueness)

It also adds in the Property Alias in place of the Property "Index" (unintended side effect, but seems cool :))
2014-06-23 20:58:42 -04:00
Kevin Giszewski f7ef096ba6 Merge branch 'master' into develop 2014-06-20 08:41:49 -04:00
Kevin Giszewski a17e5b5372 Merge branch 'master' into develop 2014-06-20 08:27:04 -04:00
kjac 16a73e0c82 Fix code formatting 2014-06-20 11:06:33 +02:00
cankoluman a56864b731 Issue #AR-6_legacy_nesting: update version counter to match VersionInfo.cs 2014-06-20 09:59:15 +01:00
kjac 2f195dd588 Add default value overload to GetValue()
Fix issue #142
2014-06-20 10:58:21 +02:00
kjac 35309b863c Fixing the unit tests
The call to DisposableTimer.DebugDuration() in
ArchetypeValueConverter.ConvertDataToSource() expects the propertyType
parameter to be not null, but the implementation of
ArchetypeValueConverter.ConvertDataToSource() allows the propertyType
parameter to be null. This breaks some of the unit tests.
I've added a null check in the call to DisposableTimer.DebugDuration()
to counter this issue.
2014-06-20 10:56:29 +02:00
cankoluman da9085c244 Merge remote-tracking branch 'upstream/develop' into dev/AR-6_legacy_nesting
Conflicts:
	app/Umbraco/Archetype.Tests/Serialization/UseCases/ArchetypeJsonConverterTest.cs
	app/Umbraco/Archetype.Tests/Serialization/UseCases/Complex/ArchetypeJsonConverterTest.cs
	app/Umbraco/Archetype.Tests/Serialization/UseCases/JsonTestModels.cs
	app/Umbraco/Umbraco.Archetype/Archetype.Umbraco.csproj
	app/Umbraco/Umbraco.Archetype/Extensions/Extensions.cs
	app/Umbraco/Umbraco.Archetype/Properties/VersionInfo.cs
	app/Umbraco/Umbraco.Archetype/Serialization/ArchetypeJsonConverter.cs
	app/Umbraco/Umbraco.Archetype/Serialization/AsArchetypeAttribute.cs
	app/Umbraco/Umbraco.Archetype/Serialization/AsFieldsetAttribute.cs
	app/Umbraco/Umbraco.Archetype/Serialization/SerializationExtensions.cs
2014-06-20 09:35:13 +01:00
cankoluman 1d8703e211 Issue #AR-6_legacy_nesting: fix issue where legacy nested model deserialization failed after the empty fieldset fix,
- add legacy deserialization test
2014-06-18 11:04:25 +01:00
kjac 0ebf07d0f4 Merge remote-tracking branch 'upstream/master' 2014-06-18 06:25:55 +02:00
Kevin Giszewski fdcd6cc3bf Bump Version to 1.2.1 2014-06-17 16:23:48 -04:00
Kevin Giszewski 59179d0c81 Fix two-way binding 2014-06-17 16:23:38 -04:00
leekelleher 16f8d9fb2a Tidied up namespace references + various whitespace.
(I couldn't help myself; OCD! )
2014-06-17 18:45:18 +01:00
leekelleher cfffa89138 Applied singleton pattern for ArchetypeHelper. 2014-06-17 18:43:58 +01:00
kjac 2b4cc2c429 Merge remote-tracking branch 'upstream/master' 2014-06-17 18:39:34 +02:00
Kevin Giszewski 9c82018903 Merge pull request #147 from leekelleher/feature/customViewPath
Added custom view path to prevalue POCO model
2014-06-17 12:16:35 -04:00
leekelleher 386a1a58fc Set the assembly references not to "copy local"
(This seems to revert when NuGet updates references)
2014-06-17 17:00:26 +01:00
leekelleher 9aaa490eb0 Added the customViewPath property to the POCO model 2014-06-17 16:59:38 +01:00
Kevin Giszewski ec446b6800 Merge branch 'pr/137' into develop 2014-06-17 07:05:06 -04:00
cankoluman 67f21ee4d8 Merge branch 'dev/AR-1_serialization' into stable 2014-06-17 11:17:23 +01:00
cankoluman 0573d99218 Merge branch 'stable' into dev/AR-1_serialization 2014-06-17 11:16:28 +01:00
cankoluman a520d86ec4 Issue #AR-5_empty_json: Handle the case where the archetype json is empty:
{""fieldsets"": []}

Currently this throws an exception. Handle by setting returned model to null.
2014-06-17 11:13:25 +01:00
kjac 1cbb7b3173 Merge with master 2014-06-16 16:57:51 +02:00
kjac 0048330863 Merge branch 'master' into issue131_optimized 2014-06-16 16:43:07 +02:00
kjac d07c16160a Merge remote-tracking branch 'upstream/master' 2014-06-16 16:42:25 +02:00
cankoluman 310771303c Merge branch 'dev/AR-1_serialization' into stable 2014-06-02 14:25:12 +01:00
kjac 71be453ada Move property files collection clean-up
Moved the cleaning up of files selected for each property to the
SerializeForPersistence() method
2014-06-01 07:48:47 +02:00
kjac efae05b3ae Merge branch 'master' into upload-imagecrop-datatypes 2014-05-29 11:17:11 +02:00
kjac aafeebfc62 Merge remote-tracking branch 'upstream/master' 2014-05-29 11:16:01 +02:00
kjac 84acd43ccf Enrich datatypes with default prevalues
Datatypes can have default prevalues, that are not saved as part of the
config and thus need to be added when loading the datatype - e.g. the
"focalPoint" prevalue for the image cropper datatype.
2014-05-29 11:14:45 +02:00
kjac 9fe756bacb Merge branch 'master' into upload-imagecrop-datatypes 2014-05-21 23:01:44 +02:00
cankoluman b6d2b7e1dd Merge branch 'dev/AR-4_delinter_fixes' into dev/AR-1_serialization 2014-05-21 14:23:26 +01:00
cankoluman 1179147041 Issue #AR-4-delinter_fixes: simplify replace 2014-05-21 14:22:11 +01:00
cankoluman 0cfcaa3364 Issue #AR-4-delinter_fixes: change heuristic for space removal 2014-05-21 14:15:54 +01:00
kjac cd03b5a4f9 Test and fine tune 3rd level nested archetypes 2014-05-20 22:19:21 +02:00
kjac 07a62d7edf More file upload handling WIP 2014-05-20 21:28:29 +02:00
cankoluman 14777a98dc Issue #AR-4-delinter_fixes: removed buggy escaped json tests 2014-05-20 16:22:47 +01:00
cankoluman a306424162 Issue #AR-4-delinter_fixes: fix issue where escaped new lines were being removed inside value quotes 2014-05-20 15:05:44 +01:00
cankoluman d124622089 Issue #AR-4-delinter_fixes: refactor delinter 2014-05-20 13:07:18 +01:00
cankoluman d9a25d1bb3 Issue #AR-4-delinter_fixes: fix all regexes except white space 2014-05-20 12:18:48 +01:00
cankoluman cda17ac754 Issue #AR-4-delinter_fixes: update remove new line 2014-05-20 10:39:09 +01:00
cankoluman d5329935aa Issue #AR-4-delinter_fixes: fixed all test failures due to jToken navigation errors.
To Do: fix erros due to incorrect space removal
2014-05-20 09:32:01 +01:00
cankoluman 1913f8bf14 Issue #AR-4-delinter_fixes: create single entry point for deserialization - 15 tests failing now 2014-05-19 16:25:20 +01:00
cankoluman 6f2eaa9859 Issue #AR-4-delinter_fixes: trying to fix delinter regex 2014-05-19 16:08:00 +01:00
kjac a6c166d926 WIP handle file selection
Use FileManager to register the files selected for properties contained
within an Archetype
2014-05-18 18:19:20 +02:00
cankoluman 31074ec9db Issue #AR-4-delinter_fixes: trying to sort out issue with \r\n being replaced inside values 2014-05-16 17:19:05 +01:00
kjac c1bc555443 Merge branch 'master' into current-value-to-value-editor 2014-05-16 13:44:46 +02:00
cankoluman 512ecbdb05 Issue #AR-1_serialization: fixes after merge of upstream master 2014-05-15 17:02:06 +01:00
cankoluman 9a97e9102e Merge branch 'master' into dev/AR-1_serialization
Conflicts:
	app/Umbraco/Archetype.Tests/Archetype.Tests.csproj
	app/Umbraco/Umbraco.Archetype.sln
	app/Umbraco/Umbraco.Archetype/Archetype.Umbraco.csproj
	app/Umbraco/Umbraco.Archetype/Extensions/Extensions.cs
	app/Umbraco/Umbraco.Archetype/PropertyConverters/ArchetypeValueConverter.cs
2014-05-15 16:48:08 +01:00
cankoluman e9b2f4aeee Merge remote-tracking branch 'upstream/master' 2014-05-15 16:43:25 +01:00
cankoluman bdb7f247c3 Issue #AR-1_serialization: add delinter to SerializeForPersistence() 2014-05-15 16:23:48 +01:00
cankoluman 08c09a8820 Issue #AR-1_serialization: moved Delinter so serialization namespace,
- fix small issue with space detection in fieldset delinter
2014-05-15 16:13:29 +01:00
cankoluman ac84c35f67 Issue #AR-1_serialization: fix issue where property alias was incorrectly set from type alias 2014-05-15 15:06:41 +01:00
cankoluman bff8bcc562 Issue #AR-1_serialization: fix overflow issue affecting deserialization in recursively nested models 2014-05-15 14:55:12 +01:00
cankoluman 8fc209abc1 Issue #AR-1_serialization: move delinter tests into serialization tests 2014-05-15 12:42:15 +01:00
cankoluman a6a961d52a Issue #AR-1_serialization: added additional unescape model tests 2014-05-15 12:38:11 +01:00
cankoluman b289892727 Issue #AR-1_serialization: initial commit of delinter 2014-05-15 12:25:44 +01:00
cankoluman 4051734313 Issue #AR-1_serialization: got json escape test to work, added json unescape extension and tests,
To Do: migrate  test code from ArcheTypePropertyEditor if possible.
2014-05-14 12:28:37 +01:00
kjac d4166f33e8 Correct currentValue for ValueEditor conversion
Ensure that the currentValue parameter sent to the fieldset property
ValueEditor ConvertEditorToDb() method contains the value that was
previously entered (if any) and not the one that was just entered.
2014-05-14 11:32:54 +02:00
cankoluman ae242feed6 Issue #AR-1_serialization: add test to try to create escaped json - this still produces unescaped json.
However,
		    internal virtual PropertyEditor GetPropertyEditor(IDataTypeDefinition dtd)
		    {
		        return dtd.Id == 0
                    ? new ArchetypePropertyEditor()
                    : PropertyEditorResolver.Current.GetByAlias(dtd.PropertyEditorAlias);
		    }

would produce nested json. But this spec looks incorrect.
2014-05-13 15:44:33 +01:00
cankoluman f1df0f2ad9 Issue #AR-1_serialization: add tests comparing models generated object serializer and archetype.SerializeForPersistence() pathwways.
Note: SerializeForPersistence() does not generate escaped json when used on its own.
All tests passing.
2014-05-13 10:20:12 +01:00
cankoluman 475fe7c81f Issue #AR-1_serialization: fix error in IsConverter when PropertyEditorAlias is null,
- relax property token navigation so that if a nested token is not found, we return null.
2014-05-12 17:15:20 +01:00
cankoluman 9b1b3d1793 Merge branch 'dev/AR-3_ienumerable_support' into dev/AR-1_serialization 2014-05-09 16:58:23 +01:00
cankoluman f1f8b7db22 Merge branch 'dev/AR-1_serialization' into dev/AR-3_ienumerable_support 2014-05-09 16:56:49 +01:00
cankoluman 475bca3c05 Merge branch 'master' into dev/AR-1_serialization 2014-05-09 16:53:51 +01:00
cankoluman 77c501f2dd Merge remote-tracking branch 'upstream/master' 2014-05-09 16:52:55 +01:00
cankoluman 5db9bb972b Issue #AR-3_IEnumerable_support: separate use case tests 2014-05-09 16:51:33 +01:00
cankoluman f931e4a31f Issue #AR-3_IEnumerable_support: fix incorrect hard-coded json, some changes to tests. 2014-05-09 16:42:30 +01:00
cankoluman bc246b947f Issue #AR-3_IEnumerable_support: add nested model regression tests 2014-05-09 15:42:58 +01:00
cankoluman ec642fa69f Issue #AR-3_IEnumerable_support: fix issue with property extraction 2014-05-09 15:27:19 +01:00
cankoluman 1ba1fa2d83 Issue #AR-3_IEnumerable_support: added compound model regression tests 2014-05-09 14:42:31 +01:00
cankoluman 7c02539751 Issue #AR-3_IEnumerable_support: re-factor regression tests 2014-05-09 13:05:04 +01:00
cankoluman bc6fff6f73 Issue #AR-3_IEnumerable_support: regression testing - fixed issue where the default fieldset name was not assigned properly during dynamic model generation 2014-05-09 11:14:39 +01:00
cankoluman 911a74e43e Issue #AR-3_IEnumerable_support: regression testing - fixes to [AsFieldset] handling,
- use ExpandoObject for all dynamically generated models
- add additional JToken parsers
- To Do: deal with multiple item fieldset
2014-05-08 16:56:51 +01:00
cankoluman 934df00281 Issue #AR-3_IEnumerable_support: start on regression tests. 2014-05-07 17:03:08 +01:00
cankoluman df8d3a8888 Issue #AR-3_IEnumerable_support: clean-up 2014-05-07 15:37:57 +01:00
cankoluman e341732f83 Issue #AR-3_IEnumerable_support: move complex model tests to sub-folder 2014-05-07 14:24:35 +01:00
cankoluman 6c5a5c8393 Issue #AR-3_IEnumerable_support: add missing tests 2014-05-07 14:17:14 +01:00
cankoluman 5e23d845d5 Issue #AR-3_IEnumerable_support: apply naming convention to unit tests 2014-05-07 14:11:26 +01:00
cankoluman 11befe727c Issue #AR-3_IEnumerable_support: all tests passing - but branching logic is difficult. 2014-05-07 13:01:07 +01:00
cankoluman ed9ba7d41f Issue #AR-3_IEnumerable_support: add IEnumerable deserialization - tests pass.
However, some regression errors in compex model use case
2014-05-06 16:54:08 +01:00
cankoluman 1ae967e002 Issue #AR-3_IEnumerable_support: add IEnumerable serialization support - Captions serialization tests passing.
- needs cleaning up.
2014-05-06 15:01:50 +01:00
cankoluman 72303c1c83 Issue #AR-3_IEnumerable_support: fix json for simple list model - simple list model passes 2014-05-06 12:13:37 +01:00
cankoluman bc6580995a Issue #AR-3_IEnumerable_support: re-factor tests, add Enumerable tests - all failing as baseline. 2014-05-06 11:39:10 +01:00
cankoluman 52ff09f089 Merge remote-tracking branch 'origin/dev/AR-2_property_value_converters' into dev/AR-1_serialization 2014-05-01 16:51:16 +01:00
cankoluman 34e65ba57e Issue #AR-1_property_value_converters: switched to using Archetype's native GetValue<T> when getting property values,
- added umbracoSettings.config to the test project: conversion of decimal numbers, e.g. '12345.34' triggers
'NormalizeNumberDecimalSeparator' which in turn requires via 'DefaultShortStringHelper' that the umbracoSettings.config file is loaded. We added this to make sure tests deserializing decimal numbers pass.
2014-05-01 16:13:19 +01:00
cankoluman 87da7e1243 Issue #AR-1_serialization: fix tests that were failing due to changes in line-end encodings. 2014-05-01 14:24:26 +01:00
cankoluman ed86255cf0 Merge branch 'master' into dev/AR-1_serialization
Conflicts:
	app/Umbraco/Umbraco.Archetype/Archetype.Umbraco.csproj
	app/Umbraco/Umbraco.Archetype/Properties/VersionInfo.cs
2014-05-01 14:17:39 +01:00
cankoluman 518f68951d Merge remote-tracking branch 'upstream/master' 2014-05-01 14:12:17 +01:00
118 changed files with 6187 additions and 2937 deletions
+5 -1
View File
@@ -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
+177 -67
View File
@@ -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,30 @@ 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']);
grunt.registerTask('assets', ['clean', 'string-replace', 'less', 'concat', 'assemblyinfo', 'copy:assets', 'copy:html', 'copy:config', 'clean:html', 'clean:js', 'clean:less']);
};
+13
View File
@@ -0,0 +1,13 @@
# Information Collection Disclosure
As of version v1.16.0, we are checking your installed version of Archetype against the current version. In this process we collect the current version of Archetype along with the current version of Umbraco that you are running. We use these values to help determine a response message to you. You may opt-out of this process by 'un-checking' the option in any of the Archetypes you have configured in the `Developer->Data Types` section of Umbraco.
![opt out](assets/optout3.png)
This is a global setting that will set an `AppSetting` and update a file located at `~/config/archetype.config.js`. If you manually change the setting it will require an app reload to refresh to runtime values. If somehow this file becomes corrupt, a new file will be generated and you will again have to opt out.
We identify your install only by a randomly generated GUID. We WILL NOT store your IP address or hostname during the update check.
Part of the reason we collect this information is to also ascertain how many active installs exist. If this number is sufficiently high, we can plan accordingly and attempt to keep this project going.
We would ask that you reach out to the Archetype team via creating an issue on this site if you have any questions or concerns. We truly want Archetype to be a win-win for all involved.
+1 -1
View File
@@ -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
+24 -5
View File
@@ -1,18 +1,37 @@
Archetype
=========
![alt tag](http://imulus.github.io/Archetype/images/logo.png)
![alt tag](http://kgiszewski.github.io/Archetype/images/logo.png)
![alt tag](http://imulus.github.io/Archetype/images/example1.png)
![alt tag](http://kgiszewski.github.io/Archetype/images/example1.png)
## 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>.
Install the selected <a href='https://github.com/kgiszewski/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) - Tonic - 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/
## Sponsor us\Donate!
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](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 :)
[Learn more](Sponsors.md) about sponsorship!
## Information Collection Disclosure
Please read the information disclosure [here](Information%20Collection%20Disclosure.md).
## 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.
+13
View File
@@ -0,0 +1,13 @@
# Sponsorship
Are you a company that depends on Archetype? We would love for you to sponsor us! Here's some suggested ways below!
## Sponsor a Sprint
We have a [backlog](https://github.com/kgiszewski/Archetype/issues), it gets worked on when either we have a personal need, we get bored or when we get a sponsorship. If you want to sponsor a sprint, we can give you thanks on social media and if you're really generous, we can put your logo and link on a well placed spot in a version release. [Contact us](https://twitter.com/ArchetypeKit) to get started.
## Donations
If you want to quietly support us, you can also send us a donation:
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KBKWLURGLGU6L)
@@ -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")]
@@ -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,56 +205,65 @@
<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\ArchetypeJsonConverterComplexModelTest.cs" />
<Compile Include="Serialization\ArchetypeJsonConverterTest.cs" />
<Compile Include="Serialization\JsonTestStrings.cs" />
<Compile Include="Serialization\JsonTestModels.cs" />
<Compile Include="PublishedContent\ArchetypePublishedContentTests.cs" />
<Compile Include="PublishedContent\TypeConverterTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
@@ -236,11 +274,22 @@
<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>
<PreBuildEvent>
</PreBuildEvent>
</PropertyGroup>
<PropertyGroup>
<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.
<Target Name="BeforeBuild">
@@ -1,21 +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 NUnit.Framework;
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()
{
@@ -34,6 +34,18 @@ namespace Archetype.Tests.Models
Assert.That(propertyValue == "Box 1 Title");
}
[Test]
public void Can_Get_Fieldset_Property_Default_Value_By_Alias()
{
var converter = new ArchetypeValueConverter();
var result = (Archetype.Models.ArchetypeModel)converter.ConvertDataToSource(null, _sampleJson, false);
var fieldset = result.Fieldsets.First();
var propertyValue = fieldset.GetValue<string>("noSuchProperty", "noSuchProperty default value");
Assert.That(propertyValue == "noSuchProperty default value");
}
[Test]
public void Can_Convert_Property_Value_Types()
{
@@ -45,7 +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 Returns_String_When_No_Type_Specified()
@@ -59,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,216 +0,0 @@
using System.Linq;
using Archetype.PropertyConverters;
using Newtonsoft.Json;
using NUnit.Framework;
namespace Archetype.Tests.Serialization
{
[TestFixture]
public class ArchetypeJsonConverterComplexModelTest
{
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 PageDetailsModel_Serializes_To_Archetype_Property()
{
var result = JsonConvert.SerializeObject(_pageDetails, Formatting.Indented);
Assert.AreEqual(JsonTestStrings._PAGE_DETAILS_JSON, result);
}
[Test]
public void ConvertComplexModelToArchetype()
{
var converter = new ArchetypeValueConverter();
var json = JsonConvert.SerializeObject(_pageDetails, Formatting.Indented);
var archetype = (Archetype.Models.ArchetypeModel)converter.ConvertDataToSource(null, json, false);
Assert.NotNull(archetype);
}
[Test]
public void DeserializeComplexModelFromArchetype()
{
var result = JsonConvert.DeserializeObject<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 SerializeThenDeserializeComplexModelFromArchetype()
{
var json = JsonConvert.SerializeObject(_pageDetails);
var result = JsonConvert.DeserializeObject<PageDetails>(json);
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 ConvertComplexNestedModelToArchetype()
{
var converter = new ArchetypeValueConverter();
var json = JsonConvert.SerializeObject(_pages, Formatting.Indented);
var archetype = (Archetype.Models.ArchetypeModel)converter.ConvertDataToSource(null, json, false);
Assert.NotNull(archetype);
}
[Test]
public void PagesModel_Serializes_To_Archetype_Property()
{
var result = JsonConvert.SerializeObject(_pages, Formatting.Indented);
Assert.AreEqual(JsonTestStrings._PAGES_JSON, result);
}
[Test]
public void DeserializeComplexTreeModelFromArchetype()
{
var result = JsonConvert.DeserializeObject<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 SerializeThenDeserializeComplexTreeModelFromArchetype()
{
var json = JsonConvert.SerializeObject(_pages);
var result = JsonConvert.DeserializeObject<PageList>(json);
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,367 +0,0 @@
using System;
using Archetype.PropertyConverters;
using Newtonsoft.Json;
using NUnit.Framework;
namespace Archetype.Tests.Serialization
{
[TestFixture]
public class ArchetypeJsonConverterTest
{
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 MergerDetailsModel_Serializes_To_Archetype_Property()
{
var result = JsonConvert.SerializeObject(_mergerDetails, Formatting.Indented);
Assert.AreEqual(JsonTestStrings._MERGER_DETAILS_JSON, result);
}
[Test]
public void ContactDetailsModel_Serializes_To_Archetype_Property()
{
var result = JsonConvert.SerializeObject(_contactDetails, Formatting.Indented);
Assert.AreEqual(JsonTestStrings._CONTACT_DETAILS_JSON, result);
}
[Test]
public void CompanyDetailsModel_Fieldset_Serializes_As_Expected()
{
var result = JsonConvert.SerializeObject(_companyDetails, Formatting.Indented);
Assert.AreEqual(JsonTestStrings._COMPANY_DETAILS_JSON, result);
}
[Test]
public void AnnualStatementModel_Fieldset_Serializes_As_Expected()
{
var result = JsonConvert.SerializeObject(_annualStatement, Formatting.Indented);
Assert.AreEqual(JsonTestStrings._ANNUAL_STATEMENT_JSON, result);
}
[Test]
public void NullValues_Serialize_To_Empty_String()
{
var result = JsonConvert.SerializeObject(new ContactDetails());
Assert.AreEqual(JsonTestStrings._NULL_VALUES_JSON, result);
}
[Test]
public void ConvertModelToArchetype()
{
var model = new ContactDetails
{
Address = "addr",
Email = "email"
};
var converter = new ArchetypeValueConverter();
var json = JsonConvert.SerializeObject(model);
var archetype = (Archetype.Models.ArchetypeModel)converter.ConvertDataToSource(null, json, false);
Assert.NotNull(archetype);
}
[Test]
public void ConvertNumericAndDateModelToArchetype()
{
var converter = new ArchetypeValueConverter();
var json = JsonConvert.SerializeObject(_annualStatement);
var archetype = (Archetype.Models.ArchetypeModel)converter.ConvertDataToSource(null, json, false);
Assert.NotNull(archetype);
}
[Test]
public void ConvertCompoundModelToArchetype()
{
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 converter = new ArchetypeValueConverter();
var json = JsonConvert.SerializeObject(model, Formatting.Indented);
var archetype = (Archetype.Models.ArchetypeModel)converter.ConvertDataToSource(null, json, false);
Assert.NotNull(archetype);
}
[Test]
public void ConvertEnumerableModelToArchetype()
{
var item1 = new ContactDetails
{
Address = "addr",
Email = "email"
};
var item2 = new ContactDetails
{
Address = "addr1",
Name = "email2"
};
var model = new ContactDetailsList
{
item1,
item2
};
var converter = new ArchetypeValueConverter();
var json = JsonConvert.SerializeObject(model, Formatting.Indented);
var archetype = (Archetype.Models.ArchetypeModel)converter.ConvertDataToSource(null, json, false);
Assert.NotNull(archetype);
}
[Test]
public void ConvertNestedModelToArchetype()
{
var model = new CompanyDetails
{
Region = "Test Region",
ContactDetails = new ContactDetails
{
Address = "addr1",
Name = "email2"
}
};
var converter = new ArchetypeValueConverter();
var json = JsonConvert.SerializeObject(model, Formatting.Indented);
var archetype = (Archetype.Models.ArchetypeModel)converter.ConvertDataToSource(null, json, false);
Assert.NotNull(archetype);
}
#endregion
#region deserialization tests
[Test]
public void DeserializeModelFromArchetype()
{
var result = JsonConvert.DeserializeObject<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 DeserializeNumericAndDateModelFromArchetype()
{
var result = JsonConvert.DeserializeObject<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 DeserializeNumericAndDateModel_NullableDate_HasValue_FromArchetype()
{
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 json = JsonConvert.SerializeObject(annualStatement);
var result = JsonConvert.DeserializeObject<AnnualStatement>(json);
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 DeserializeCompoundModelFromArchetype()
{
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 json = JsonConvert.SerializeObject(model, Formatting.Indented);
var result = JsonConvert.DeserializeObject<AllContactDetails>(json);
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 DeserializeEnumerableModelFromArchetype()
{
var item1 = new ContactDetails
{
Address = "addr",
Email = "email"
};
var item2 = new ContactDetails
{
Address = "addr1",
Name = "email2"
};
var model = new ContactDetailsList
{
item1,
item2
};
var json = JsonConvert.SerializeObject(model, Formatting.Indented);
var result = JsonConvert.DeserializeObject<ContactDetailsList>(json);
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 DeserializeNestedModelFromArchetype()
{
var model = new CompanyDetails
{
Region = "Test Region",
ContactDetails = new ContactDetails
{
Address = "addr1",
Name = "email2"
}
};
var json = JsonConvert.SerializeObject(model, Formatting.Indented);
var result = JsonConvert.DeserializeObject<CompanyDetails>(json);
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
}
}
@@ -1,179 +0,0 @@
using System;
using System.Collections.Generic;
using Archetype.Serialization;
using Newtonsoft.Json;
namespace Archetype.Tests.Serialization
{
#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
#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,435 +0,0 @@
namespace Archetype.Tests.Serialization
{
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 _PAGE_DETAILS_JSON =
@"{
""fieldsets"": [
{
""alias"": ""pages"",
""properties"": [
{
""alias"": ""pages"",
""value"": ""2439,2440,2441,2442,2443,2444,2445,2446,2447,2448,2449,2450,2451,2452,2453""
}
]
},
{
""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""
}
]
}
]
}
}
]
}
]
}";
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""
}
]
}
]
}
}
]
}
]
}";
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"":""""}]}]}";
}
}
+9 -1
View File
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<configSections>
<sectionGroup name="umbracoConfiguration">
<section name="settings" type="Umbraco.Core.Configuration.UmbracoSettings.UmbracoSettingsSection, Umbraco.Core" requirePermission="false" />
</sectionGroup>
</configSections>
<umbracoConfiguration>
<settings configSource="config\umbracoSettings.config" />
</umbracoConfiguration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+1 -1
View File
@@ -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" />
-49
View File
@@ -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")]
-27
View File
@@ -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>
+8 -6
View File
@@ -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,64 @@ 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
{
private static DateTime _lastVersionCheck;
private const int IntervalInDaysBetweenVersionChecks = 7;
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>System.Object.</returns>
public object GetAll()
{
var dataTypes = Services.DataTypeService.GetAllDataTypeDefinitions();
return dataTypes.Select(t => new { guid = t.Key, name = t.Name });
}
/// <summary>
/// Gets all details.
/// </summary>
/// <returns>System.Object.</returns>
public object GetAllDetails()
{
var dataTypes = Services.DataTypeService.GetAllDataTypeDefinitions();
var list = new List<object>();
foreach (var dataType in dataTypes)
{
var dataTypeDisplay = Mapper.Map<IDataTypeDefinition, DataTypeDisplay>(dataType);
list.Add(new { selectedEditor = dataTypeDisplay.SelectedEditor, preValues = dataTypeDisplay.PreValues, dataTypeGuid = dataType.Key });
}
return list;
}
/// <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 +73,99 @@ 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 || !IsItTimeToCheck())
{
return new
{
isUpdateAvailable = false
};
}
var updateNotificationModel = ArchetypeHelper.Instance.CheckForUpdates();
_lastVersionCheck = DateTime.UtcNow;
return new
{
isUpdateAvailable = updateNotificationModel.IsUpdateAvailable,
headline = updateNotificationModel.Headline,
type = updateNotificationModel.Type,
message = updateNotificationModel.Message,
url = updateNotificationModel.Url
};
}
internal bool IsItTimeToCheck()
{
return _lastVersionCheck.AddDays(IntervalInDaysBetweenVersionChecks) < DateTime.UtcNow;
}
}
}
@@ -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>
@@ -42,6 +42,7 @@
</Reference>
<Reference Include="businesslogic">
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\businesslogic.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ClientDependency.Core">
<HintPath>..\packages\ClientDependency.1.7.1.2\lib\ClientDependency.Core.dll</HintPath>
@@ -53,9 +54,11 @@
</Reference>
<Reference Include="cms">
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\cms.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="controls">
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\controls.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="CookComputing.XmlRpcV2">
<HintPath>..\packages\xmlrpcnet.2.5.0\lib\net20\CookComputing.XmlRpcV2.dll</HintPath>
@@ -63,6 +66,7 @@
</Reference>
<Reference Include="Examine">
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\Examine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="HtmlAgilityPack">
<HintPath>..\packages\HtmlAgilityPack.1.4.6\lib\Net45\HtmlAgilityPack.dll</HintPath>
@@ -74,15 +78,19 @@
</Reference>
<Reference Include="ImageProcessor">
<HintPath>..\packages\ImageProcessor.1.9.0.0\lib\ImageProcessor.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ImageProcessor.Web">
<HintPath>..\packages\ImageProcessor.Web.3.2.3.0\lib\net45\ImageProcessor.Web.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="Lucene.Net">
<HintPath>..\packages\Lucene.Net.2.9.4.1\lib\net40\Lucene.Net.dll</HintPath>
@@ -90,9 +98,11 @@
</Reference>
<Reference Include="Microsoft.ApplicationBlocks.Data">
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\Microsoft.ApplicationBlocks.Data.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Web.Helpers">
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\Microsoft.Web.Helpers.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>False</Private>
@@ -116,15 +126,17 @@
</Reference>
<Reference Include="SQLCE4Umbraco">
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\SQLCE4Umbraco.dll</HintPath>
<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>True</Private>
<Private>False</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>
<Private>False</Private>
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\System.Data.SqlServerCe.Entity.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http" />
@@ -173,58 +185,79 @@
<Reference Include="System.Xml" />
<Reference Include="TidyNet">
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\TidyNet.dll</HintPath>
<Private>False</Private>
</Reference>
<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.DataLayer">
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\umbraco.DataLayer.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="umbraco.editorControls">
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\umbraco.editorControls.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="umbraco.MacroEngines">
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\umbraco.MacroEngines.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>
<Reference Include="Umbraco.Web.UI">
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\Umbraco.Web.UI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="umbraco.XmlSerializers">
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\umbraco.XmlSerializers.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UmbracoExamine">
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\UmbracoExamine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UrlRewritingNet.UrlRewriter">
<HintPath>..\packages\UmbracoCms.Core.7.1.2\lib\UrlRewritingNet.UrlRewriter.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<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\AsArchetypeAttribute.cs" />
<Compile Include="Serialization\ArchetypeJsonConverter.cs" />
<Compile Include="Serialization\AsFieldsetAttribute.cs" />
<Compile Include="Serialization\SerializationExtensions.cs" />
<Compile Include="PropertyEditors\ArchetypePropertyEditor.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,33 +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;
protected ApplicationContext _app;
/// <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();
internal 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();
}
}
}
return _instance;
}
}
/// <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
{
@@ -37,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
{
@@ -61,18 +132,83 @@ 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();
}
}
private ArchetypePreValue GetArchetypePreValueFromDataTypeId(int dataTypeId)
{
/// <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(
Constants.CacheKey_PreValueFromDataTypeId + dataTypeId,
() =>
@@ -89,8 +225,13 @@ namespace Archetype.Extensions
return config;
}) 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;
@@ -98,10 +239,14 @@ 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(
return (IDataTypeDefinition)ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem(
Constants.CacheKey_DataTypeByGuid + guid,
() => _app.Services.DataTypeService.GetDataTypeDefinitionById(guid));
}
@@ -111,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)
{
@@ -121,7 +267,7 @@ namespace Archetype.Extensions
foreach (var property in fieldset.Properties)
{
var propertyAlias = property.Alias;
foreach ( var propertyInst in fieldsetInst.Properties.Where(x => x.Alias == propertyAlias))
foreach (var propertyInst in fieldsetInst.Properties.Where(x => x.Alias == propertyAlias))
{
propertyInst.DataTypeGuid = property.DataTypeGuid.ToString();
propertyInst.DataTypeId = GetDataTypeByGuid(property.DataTypeGuid).Id;
@@ -136,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)
{
@@ -149,5 +294,17 @@ 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,18 +1,44 @@
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")]
public string Alias { get; set; }
[JsonProperty("disabled")]
public bool Disabled { get; set; }
[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>();
@@ -20,26 +46,83 @@ 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 (property == null || property.Value == null || string.IsNullOrEmpty(property.Value.ToString()))
if (IsEmptyProperty(property))
{
return default(T);
}
return property.GetValue<T>();
}
// issue 142: support default T value supplied by caller
// this code would look nicer if the two GetValue<T>() methods had one common implementation.
// 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))
{
return defaultValue;
}
return property.GetValue<T>();
}
/// <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);
@@ -49,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,37 +1,58 @@
using System;
using System.Collections;
using System.Collections.Generic;
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.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))
@@ -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,18 +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; }
@@ -44,7 +73,16 @@ namespace Archetype.Models
[JsonProperty("customJsPath")]
public string CustomJsPath { get; set; }
[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.2")]
[assembly: AssemblyFileVersion("1.2-beta")]
[assembly: AssemblyVersion("1.17.1")]
[assembly: AssemblyFileVersion("1.17.1")]
@@ -1,35 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Archetype.Extensions;
using Archetype.Extensions;
using Archetype.Models;
using Newtonsoft.Json;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
namespace Archetype.PropertyConverters
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 propertyType.PropertyEditorAlias.Equals(Constants.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 Models.ArchetypeModel();
var defaultValue = new ArchetypeModel();
if (source == null)
return defaultValue;
@@ -39,11 +60,14 @@ namespace Archetype.PropertyConverters
if (!sourceString.DetectIsJson())
return defaultValue;
var archetype = new ArchetypeHelper().DeserializeJsonToArchetype(source.ToString(),
(propertyType != null ? propertyType.DataTypeId : -1),
(propertyType != null ? propertyType.ContentType : null));
using (var timer = DisposableTimer.DebugDuration<ArchetypeValueConverter>(string.Format("ConvertDataToSource ({0})", propertyType != null ? propertyType.PropertyTypeAlias : "null")))
{
var archetype = ArchetypeHelper.Instance.DeserializeJsonToArchetype(sourceString,
(propertyType != null ? propertyType.DataTypeId : -1),
(propertyType != null ? propertyType.ContentType : null));
return archetype;
return archetype;
}
}
}
}
@@ -1,34 +1,45 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Archetype.Extensions;
using Archetype.Models;
using ClientDependency.Core;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Editors;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Web.PropertyEditors;
using Umbraco.Core.Logging;
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; }
@@ -41,105 +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 = new ArchetypeHelper().DeserializeJsonToArchetype(property.Value.ToString(), propertyType.DataTypeDefinitionId);
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 = new ArchetypeHelper().DeserializeJsonToArchetype(property.Value.ToString(), propertyType.DataTypeDefinitionId);
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;
var archetype = new ArchetypeHelper().DeserializeJsonToArchetype(editorValue.Value.ToString(), editorValue.PreValues);
// 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();
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,354 +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 Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Archetype.Serialization
{
public class ArchetypeJsonConverter : JsonConverter
{
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 = new JObject
{
{
"fieldsets",
new JArray( new JRaw(SerializeModels(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;
var obj = Activator.CreateInstance(objectType);
if (null != obj as IEnumerable<object>
&& jToken["fieldsets"] != null && jToken["fieldsets"].Any())
{
return DeserializeEnumerableObject(obj, jToken);
}
return null == jToken as JArray
? DeserializeObject(obj, jToken)
: PopulateProperties(obj, jToken);
}
public override bool CanConvert(Type objectType)
{
return IsValueArchetypeDatatype(objectType);
}
#region private methods
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 };
var dynamicModel = new ExpandoObject() as IDictionary<string, object>;
foreach (var pInfo in properties.Where(pInfo => !HasAsFieldsetAttribute(pInfo)))
{
dynamicModel.Add(GetJsonPropertyName(pInfo), pInfo.GetValue(value));
}
var fieldsetModels = properties.Where(HasAsFieldsetAttribute)
.Select(pInfo => pInfo.GetValue(value));
models = new List<object>
{
dynamicModel,
};
models = ((IEnumerable<object>)models).Concat(fieldsetModels).ToList();
return models;
}
private object DeserializeEnumerableObject(object obj, JToken jToken)
{
var model = obj as IEnumerable<object>;
var itemType = model.GetType().BaseType.GetGenericArguments().First();
foreach (var fs in jToken["fieldsets"].Where(fs => fs["alias"].ToString().Equals(GetFieldsetName(itemType))))
{
var item = JsonConvert.DeserializeObject(
fs["properties"].ToString(), itemType, GetArchetypeDatatypeConverter());
obj.GetType().GetMethod("Add").Invoke(obj, new[] { item });
}
return obj;
}
private object DeserializeObject(object obj, JToken jToken)
{
var properties = GetSerialiazableProperties(obj).ToList();
var asFieldset = properties.Where(HasAsFieldsetAttribute).ToList();
foreach (var propInfo in asFieldset)
{
var propAlias = GetJsonPropertyName(propInfo);
var fsJToken = GetFieldsetProperties(propInfo.PropertyType, jToken);
var propJToken =
fsJToken.Single(p => p.SelectToken("alias").ToString().Equals(propAlias));
if (propJToken == null)
continue;
var propValue = IsValueArchetypeDatatype(propInfo.PropertyType)
? JsonConvert.DeserializeObject(fsJToken.ToString(), propInfo.PropertyType,
GetArchetypeDatatypeConverter())
: GetDeserializedPropertyValue(fsJToken, propInfo.PropertyType); ;
propInfo.SetValue(obj, propValue);
}
return PopulateProperties(obj, GetFieldsetProperties(obj.GetType(), jToken));
}
private JToken GetFieldsetProperties(Type objType, JToken jToken)
{
var objAlias = GetFieldsetName(objType);
return
jToken["fieldsets"].Single(p => p.SelectToken("alias").ToString().Equals(objAlias)).SelectToken("properties");
}
private object PopulateProperties(object obj, JToken jToken)
{
var properties = GetSerialiazableProperties(obj);
foreach (var propertyInfo in properties)
{
var propAlias = GetJsonPropertyName(propertyInfo);
var propJToken = jToken.SingleOrDefault(p => p.SelectToken("alias").ToString().Equals(propAlias));
if (propJToken == null)
continue;
var propValue = GetPropertyValue(propertyInfo, propJToken);
propertyInfo.SetValue(obj, propValue);
}
return obj;
}
private object GetPropertyValue(PropertyInfo propertyInfo, JToken propJToken)
{
return IsValueArchetypeDatatype(propertyInfo.PropertyType)
? JsonConvert.DeserializeObject(propJToken["value"].ToString(), propertyInfo.PropertyType,
GetArchetypeDatatypeConverter())
: GetDeserializedPropertyValue(propJToken["value"], propertyInfo.PropertyType);
}
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 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 IsExpandoObject(object value)
{
return value.GetType().Name.Equals(typeof (ExpandoObject).Name);
}
private JObject GetJObjectFromExpandoObject(IEnumerable<KeyValuePair<string, object>> obj)
{
var property = obj.ElementAt(0);
var alias = property.Key;
var value = property.Value;
var jObj = new JObject
{
{
"alias",
new JValue(alias)
}
};
var fsProperties = new List<JObject>
{
new JObject {new JProperty("alias", alias), new JProperty("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 = GetSerialiazableProperties(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.GetValue(obj, null);
fsProperty.Add(
new JProperty("value",
IsValueArchetypeDatatype(propValue)
? new JRaw(JsonConvert.SerializeObject(propValue,
GetArchetypeDatatypeConverter()))
: new JValue(GetSerializedPropertyValue(propValue))));
fsProperties.Add(fsProperty);
}
jObj.Add("properties", new JRaw(JsonConvert.SerializeObject(fsProperties)));
return jObj;
}
private IEnumerable<PropertyInfo> GetSerialiazableProperties(object obj)
{
return obj.GetType()
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
.Where(prop => !Attribute.IsDefined(prop, typeof(JsonIgnoreAttribute)));
}
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 bool IsValueArchetypeDatatype(object value)
{
return value != null &&
IsValueArchetypeDatatype(value.GetType());
}
private bool IsValueArchetypeDatatype(Type type)
{
return type.GetCustomAttributes(typeof(AsArchetypeAttribute), true).Length > 0;
}
private JsonConverter GetArchetypeDatatypeConverter()
{
return (JsonConverter)Activator.CreateInstance(GetType());
}
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)
{
if (String.IsNullOrEmpty(jToken.ToString()))
return GetDefault(type);
var localType = Nullable.GetUnderlyingType(type) ?? type;
if (localType == typeof(bool))
return jToken.ToString() == "1";
return localType == typeof(DateTime)
? Convert.ToDateTime(jToken.ToString())
: jToken.ToObject(localType);
}
private object GetDefault(Type type)
{
return type.IsValueType ? Activator.CreateInstance(type) : null;
}
#endregion
}
}
@@ -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,32 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 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));
}
}
}
@@ -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);
}
}
}
+64 -17
View File
@@ -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, "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();
}
});
+761 -46
View File
@@ -1,4 +1,10 @@
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;
var isCacheInitialized = false;
//$scope.model.value = "";
$scope.model.hideLabel = $scope.model.config.hideLabel == 1;
@@ -11,51 +17,347 @@
//ini the model
$scope.model.value = $scope.model.value || getDefaultModel($scope.model.config);
// 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();
//helper to get $eval the labelTemplate
$scope.getFieldsetTitle = function(fieldsetConfigModel, fieldsetIndex) {
if(!fieldsetConfigModel)
$scope.fieldsetTitles = [];
$scope.getFieldsetTitle = function (fieldsetConfigModel, fieldsetIndex) {
if(!isCacheInitialized) {
return "";
var fieldset = $scope.model.value.fieldsets[fieldsetIndex];
var fieldsetConfig = $scope.getConfigFieldsetByAlias(fieldset.alias);
var template = fieldsetConfigModel.labelTemplate;
}
// Ensure the collection of titles is large enough.
ensureEnoughTitles(fieldsetIndex + 1);
var title = $scope.fieldsetTitles[fieldsetIndex];
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 the title if it's already been loaded.
if (title.loaded) {
return title.value;
}
return parsedTemplate;
// Return early if the title is still loading.
if (title.loading) {
return;
}
// Start loading the title.
title.loading = true;
title.loaded = false;
title.value = null;
archetypeLabelService.getFieldsetTitle($scope, fieldsetConfigModel, fieldsetIndex).then(function(value) {
// Finished loading the title.
title.loaded = true;
title.loading = false;
title.value = value;
});
};
/**
* Ensure the collection of fieldset titles is large enough to accommodate the number of fieldsets.
* @param count The number of fieldsets.
*/
function ensureEnoughTitles(count) {
while ($scope.fieldsetTitles.length < count) {
$scope.fieldsetTitles.push({
loading: false,
loaded: false,
value: null
});
}
}
//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.getEditors().addClass('archetypeDragging');
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);
archetypeService.getEditors().removeClass('archetypeDragging');
}
};
// 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')
@@ -67,10 +369,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();
}
}
@@ -79,13 +393,73 @@
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);
}
}
}
$scope.enableDisable = function (fieldset) {
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;
@@ -94,31 +468,131 @@
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 () {
return $scope.model.config.enableDisabling;
}
//helpers for determining if the add button should be shown
$scope.showAddButton = function () {
var visible = countVisible();
return (visible === 0 && $scope.model.config.startWithAddButton)
|| (visible > 0 && $scope.canAdd());
}
//helper for determining if no content is available yet
$scope.showEmptyContentHint = function () {
return $scope.model.config.startWithAddButton
&& countVisible() === 0;
///&& $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);
archetypeCacheService.initialize().then(function() {
isCacheInitialized = true;
});
$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)
@@ -130,6 +604,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){
@@ -149,9 +653,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
@@ -162,40 +672,84 @@
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);
}
// Deep watch for changes.
$scope.$watch('model.value', function () {
// Empty titles. If the value has changed, the titles may have changed.
$scope.fieldsetTitles = [];
}, true);
//watch for changes
$scope.$watch('model.value', function (v) {
if ($scope.model.config.developerMode) {
@@ -205,6 +759,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
@@ -263,6 +833,24 @@
return (typeof property == 'undefined') ? true : property.isValid;
}
//helper to lookup validity when given a fieldset
$scope.getFieldsetValidity = function (fieldset) {
// Variables.
var valid = true;
// Recursive validation of nested fieldsets.
recurseFieldsets(function(item) {
if (item.isValid === false) {
valid = false;
}
}, [fieldset]);
// Were all the nested fieldsets valid?
return valid;
};
// helper to force the current form into the dirty state
$scope.setDirty = function () {
if($scope.form) {
@@ -270,17 +858,144 @@
}
}
$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: '@'
+29
View File
@@ -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);
});
}
};
});
+5 -14
View File
@@ -1,18 +1,12 @@
angular.module("umbraco.directives").directive('archetypeCustomView', function ($compile, $http) {
var linker = function (scope, element, attrs) {
var config = scope.archetype.config.archetypeConfig;
var view = "/App_plugins/Archetype/views/archetype.default.html";
if(config.customViewPath) {
view = config.customViewPath;
var view = "../App_plugins/Archetype/views/archetype.default.html";
if(scope.model.config.customViewPath) {
view = scope.model.config.customViewPath;
}
$http.get(view).then(function(data) {
scope.model = {};
scope.model.value = scope.archetype.value;
scope.model.config = scope.archetype.config;
$http.get(view, { cache: true }).then(function(data) {
element.html(data.data).show();
@@ -23,9 +17,6 @@ angular.module("umbraco.directives").directive('archetypeCustomView', function (
return {
restrict: "A",
replace: true,
link: linker,
scope: {
archetype: "="
}
link: linker
}
});
+111 -135
View File
@@ -1,76 +1,28 @@
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) {
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 umbracoPropertyAlias = scope.umbracoPropertyAlias;
// 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;
//determine the view to use [...] and load it
@@ -85,80 +37,15 @@ angular.module("umbraco.directives").directive('archetypeProperty', function ($c
var mergedConfig = _.extend(defaultConfigObj, config);
loadView(pathToView, mergedConfig, defaultValue, alias, umbracoPropertyAlias, 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);
}
}
function loadView(view, config, defaultValue, alias, umbracoPropertyAlias, 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')
{
@@ -171,28 +58,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-" + umbracoPropertyAlias + "-" + scope.fieldsetIndex + "-" + scope.propertyConfigIndex;
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();
@@ -216,6 +191,7 @@ angular.module("umbraco.directives").directive('archetypeProperty', function ($c
scope: {
property: '=',
propertyConfigIndex: '=',
propertyEditorAlias: '=',
archetypeConfig: '=',
fieldset: '=',
fieldsetIndex: '=',
+25
View File
@@ -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: '='
}
}
});
+51
View File
@@ -0,0 +1,51 @@
//create a namespace (optional)
var ArchetypeSampleLabelHelpers = {};
//create a function
//you will add it to your label template field as `{{ArchetypeSampleLabelHelpers.testPromise(someArchetypePropertyAlias)}}`
ArchetypeSampleLabelHelpers.testPromise = function(value) {
//you can inject services
return function ($timeout, archetypeCacheService) {
//best to return a promise
//NOTE: $timeout returns a promise
return $timeout(function () {
return "As Promised: " + value;
}, 1000);
}
}
ArchetypeSampleLabelHelpers.testEntityPromise = function(value, scope, args) {
//hey look, args!
//{{ArchetypeSampleLabelHelpers.testEntityPromise(someArchetypePropertyAlias, {foo: 1})}}
console.log(args);
return function ($q, entityResource) {
var deferred = $q.defer();
entityResource.getById(args.foo, 'document').then(function(entity) {
console.log("Hello from testEntityPromise");
console.log(entity);
deferred.resolve(entity.name);
});
return deferred.promise;
}
}
ArchetypeSampleLabelHelpers.testEntityPromise2 = function(value, scope, args) {
//hey look, args but we're also using the built-in archetypeCacheService
//{{ArchetypeSampleLabelHelpers.testEntityPromise(someArchetypePropertyAlias, {foo: 1234})}}
console.log(args);
return function ($q, archetypeCacheService) {
var deferred = $q.defer();
archetypeCacheService.getEntityById(args.foo, 'document').then(function(entity) {
console.log("Hello from testEntityPromise2");
console.log(entity);
deferred.resolve(entity.name);
});
return deferred.promise;
}
}
+28 -1
View File
@@ -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",
@@ -31,5 +32,31 @@
"properties": "Egenskaber",
"labelTemplate": "Label skabelon",
"select": "Vælg",
"icon": "Ikon"
"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)"
}
+62
View File
@@ -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)"
}
+14 -1
View File
@@ -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",
@@ -31,5 +32,17 @@
"properties": "Properties",
"labelTemplate": "Label Template",
"select": "Select",
"icon": "Icon"
"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"
}
+48
View File
@@ -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"
}
+18 -3
View File
@@ -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",
@@ -31,5 +32,19 @@
"properties": "Properties",
"labelTemplate": "Label Template",
"select": "Select",
"icon": "Icon"
"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"
}
+18 -3
View File
@@ -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",
@@ -31,5 +32,19 @@
"properties": "Properties",
"labelTemplate": "Label Template",
"select": "Select",
"icon": "Icon"
"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"
}
+50
View File
@@ -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"
}
+14 -1
View File
@@ -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",
@@ -31,5 +32,17 @@
"properties": "Properties",
"labelTemplate": "Label Template",
"select": "Select",
"icon": "Icon"
"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"
}
+48
View File
@@ -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"
}
+14 -1
View File
@@ -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",
@@ -31,5 +32,17 @@
"properties": "Properties",
"labelTemplate": "Label Template",
"select": "Select",
"icon": "Icon"
"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"
}
+14 -1
View File
@@ -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",
@@ -31,5 +32,17 @@
"properties": "Properties",
"labelTemplate": "Label Template",
"select": "Select",
"icon": "Icon"
"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"
}
+14 -1
View File
@@ -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",
@@ -31,5 +32,17 @@
"properties": "Properties",
"labelTemplate": "Label Template",
"select": "Select",
"icon": "Icon"
"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"
}
+14 -1
View File
@@ -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",
@@ -31,5 +32,17 @@
"properties": "Properties",
"labelTemplate": "Label Template",
"select": "Select",
"icon": "Icon"
"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"
}
+14 -1
View File
@@ -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",
@@ -31,5 +32,17 @@
"properties": "Properties",
"labelTemplate": "Label Template",
"select": "Select",
"icon": "Icon"
"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"
}
+14 -1
View File
@@ -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",
@@ -31,5 +32,17 @@
"properties": "Properties",
"labelTemplate": "Label Template",
"select": "Select",
"icon": "Icon"
"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"
}
+14 -1
View File
@@ -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",
@@ -31,5 +32,17 @@
"properties": "Properties",
"labelTemplate": "Label Template",
"select": "Select",
"icon": "Icon"
"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"
}
+14 -1
View File
@@ -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",
@@ -31,5 +32,17 @@
"properties": "Properties",
"labelTemplate": "Label Template",
"select": "Select",
"icon": "Icon"
"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"
}
+14 -1
View File
@@ -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",
@@ -31,5 +32,17 @@
"properties": "Properties",
"labelTemplate": "Label Template",
"select": "Select",
"icon": "Icon"
"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"
}
+14 -1
View File
@@ -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",
@@ -31,5 +32,17 @@
"properties": "Properties",
"labelTemplate": "Label Template",
"select": "Select",
"icon": "Icon"
"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"
}
+14 -1
View File
@@ -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",
@@ -31,5 +32,17 @@
"properties": "Properties",
"labelTemplate": "Label Template",
"select": "Select",
"icon": "Icon"
"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"
}
+14 -1
View File
@@ -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",
@@ -31,5 +32,17 @@
"properties": "Properties",
"labelTemplate": "Label Template",
"select": "Select",
"icon": "Icon"
"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"
}
+643 -260
View File
@@ -1,321 +1,714 @@
.archetypeEditor {
{{VERSION}}
.archetypeEditor {
width: 98%;
.usky-grid {
.cell-tools-menu {
height: 385px;
}
&.withGroups {
.cell-tools-menu {
height: 415px;
}
}
}
.open {
position: relative;
}
.dropdown-menu {
top: auto;
}
}
.archetypeEditor fieldset{
border: 1px solid #dddddd;
padding: 0;
margin-bottom: 5px;
background-color: #f1f1f1;
clear: both;
display: inline-block;
width: 100%;
}
.archetypeEditor .archetypeFieldsetLabel {
position: relative;
width: 100%%;
.label-sub {
padding: 8px 0;
display: inline-block;
&.module-label {
width: 100%;
> li > a {
border-radius: 6px;
}
}
.dropdown-menu {
padding: 0;
border-radius: 0;
box-shadow: none;
margin-top: -10px;
margin-left: -200px;
.controls-no-label {
padding: 10px;
}
span {
font-weight: bold;
&.menu-label { font-weight: normal; }
a+ul.dropdown-menu {
margin-left: 0;
}
label:hover {
cursor: default;
}
&.enableCollapsing:hover {
cursor: pointer;
label {
span {
text-decoration: underline;
}
&:hover {
cursor: pointer;
}
}
.fieldsetIcon {
float: left;
padding: 0 10px 0 0;
vertical-align: text-bottom;
}
.caret {
margin: 8px 1px 0 15px;
margin: 8px 1px 0 2px;
&.caret-right {
border-bottom: 4px solid transparent;
border-top: 4px solid transparent;
border-left: 4px solid #000000;
border-left: 4px solid #ddd;
content: "";
margin-top: 6px;
}
}
label{
margin-bottom: 0;
margin-left: 5px;
fieldset {
border-bottom: 1px dashed #dddddd;
padding: 0;
span {
display: inline-block;
clear: both;
display: inline-block;
width: 100%;
.archetypeProperty {
clear: both;
overflow: visible;
margin-top: 3px;
label {
padding-left: 5px !important;
span {
color: #343434;
}
&.dimmed span {
color: #d9d9d9;
}
}
.publishOptions {
.publishDate {
display: inline-block;
vertical-align: top;
margin-right: 20px;
label {
padding: 0 !important;
margin: 0 !important;
}
}
}
}
.archetypeFieldsetLabel {
position: relative;
width: 100%;
background: white;
.label-sub {
padding: 18px 0;
display: inline-block;
min-height: 20px; /* this makes the header clickable when there's no icon and no text */
&.module-label {
width: 100%;
}
&:hover {
cursor: pointer;
label {
// span {
// text-decoration: underline;
// }
&:hover {
cursor: pointer;
}
}
.caret-right {
border-left-color: #333;
}
}
}
.dropdown-menu {
position: relative;
padding: 0;
border-radius: 0;
box-shadow: none;
margin-top: -10px;
}
span {
// font-weight: bold;
&.menu-label { font-weight: normal; }
}
label:hover {
cursor: default;
}
.caret {
position: absolute;
}
label {
margin-bottom: 0;
margin-left: 18px;
padding: 0;
display: block;
span {
display: block;
overflow: hidden;
text-overflow: ellipsis;
max-height: 40px;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
display: -webkit-box;
}
}
&.dimmed {
label {
color: #d9d9d9 !important;
}
}
.archetypeEditorControls {
float: none;
position: absolute;
right: 0;
top: 0;
height: 100%;
padding: 0;
display: flex;
align-items: center;
opacity: 0;
transition: opacity .15s ease-in-out;
-moz-transition: opacity .15s ease-in-out;
-webkit-transition: opacity .15s ease-in-out;
background: white;
&:before {
content: ' ';
position: absolute;
display: block;
left: -40px;
width: 40px;
top: 0;
bottom: 0;
background: -webkit-linear-gradient(90deg, rgba(255,255,255,0), white);
background: -moz-linear-gradient(90deg, rgba(255,255,255,0), white);
background: linear-gradient(90deg, rgba(255,255,255,0), white);
}
.icon {
display: inline-block;
height: 28px;
width: 28px;
line-height: 28px;
border-radius: 14px;
border: 1px solid #d6d6d6;
color: #5f5f5f;
background: white;
font-size: 16px;
text-align: center;
margin-left: 8px;
&:hover {
background: #f3f3f5;
}
&.icon-trash:hover {
background: #fe5b57;
border-color: #fe5b57;
color: white;
}
&.icon-disabled {
cursor: default;
&:hover {
color: #ddd;
background: white;
}
}
&.icon-active {
color: #bbb;
&:hover {
color: white;
}
}
}
}
&:hover .archetypeEditorControls {
opacity: 1;
}
}
&.is-open > .archetypeFieldsetLabel .archetypeEditorControls {
opacity: 1;
}
.archetypePropertyError {
margin-bottom: 5px;
padding-top: 3px;
padding-bottom: 3px;
label {
span {
color: #b94a48;
font-weight: bold;
}
}
}
.archetypeCollapser {
clear: both;
height: 100%;
padding: 24px 20px 0 20px;
background-color: #fafafa;
border-top: 1px dashed #e0e0e0;
line-height: 20px;
.archetypeFieldsetLabel {
background: #fafafa;
}
.archetypeEditorControls {
background: #fafafa;
&:before {
background: -webkit-linear-gradient(90deg, rgba(250,250,250,0), #fafafa);
background: -moz-linear-gradient(90deg, rgba(250,250,250,0), #fafafa);
background: linear-gradient(90deg, rgba(250,250,250,0), #fafafa);
}
}
form {
margin-left:20px;
.control-label {
padding-top: 0 !important;
}
}
.archetypeFieldsetHelpText {
clear:both;
margin-bottom: 3px;
font-size: 12px;
}
}
}
}
.archetypeEditor .archetypeCollapser{
clear: both;
height: 100%;
padding-top: 12px;
background-color: #fff;
border-top: 1px solid silver;
border-radius: 0 0 0 5px;
}
.archetypeDeveloperModel
{
font-family: monospace;
width: 98%;
min-height: 100px;
margin-bottom: 10px;
border: 1px solid red;
}
.archetypeEditor .multiPropertyTextbox{
margin-bottom: 3px;
}
.archetypeFieldsetError {
border: 1px solid #b94a48;
}
.archetypeEditor ul{
list-style: none;
margin-left: 0;
}
.archetypeFooter {
text-align: center;
margin-top: 20px;
}
.archetypeEditor,
.archetypeConfig {
.archetypeEditorControls {
float: right;
.archetypeAddButton {
display: inline-block;
height: 28px;
width: 28px;
line-height: 28px;
border-radius: 14px;
border: 1px solid #b6b6b6;
color: #5f5f5f;
background: white;
font-size: 16px;
text-align: center;
text-decoration: none;
cursor: pointer;
i {
cursor: pointer;
&.handle {
cursor: move;
&:hover {
background: #00aea2;
border-color: #00aea2;
color: white;
}
}
.archetypeEmptyContent {
text-align: center;
margin-bottom: 20px;
span {
display: inline-block;
padding: 10px 20px;
clear: both;
font-size: 14px;
color: #555;
background: #f8f8f8;
border-radius: 15px;
}
}
.archetypeCrossDraggable + .archetypeEmptyContent {
margin-top: -42px;
}
&.archetypeDragging .archetypeCrossDraggable + .archetypeEmptyContent {
display: none;
}
// Necessary to ensure empty lists can be dropped onto when sorting nested fieldsets.
.archetypeSortable.archetypeEmpty.archetypeCrossDraggable {
min-height: 40px;
border: 1px dashed transparent;
}
&.archetypeDragging .archetypeSortable.archetypeEmpty.archetypeCrossDraggable {
min-height: 56px;
border-color: #dddddd;
}
.archetypeCollapser .archetypeEmptyContent span {
background: #f2f2f2;
}
.multiPropertyTextbox {
margin-bottom: 3px;
}
ul {
list-style: none;
margin-left: 0;
}
li {
line-height: 20px;
}
.show-validation.ng-invalid .control-group.error .control-label {
span {
color: #343434;
}
}
.fieldsetPicker {
.icon {
color: #333;
}
ul.elements li {
overflow: visible;
vertical-align: top;
height: 90px;
.fieldsetPreviewOpen {
font-style: italic;
a:hover {
text-decoration: underline;
}
}
}
ul.groups {
display: block;
margin: 0;
padding: 4px;
li {
width: auto;
margin: 0;
padding: 0 20px;
font-weight: bold;
a {
color: #d9d9d9;
cursor: pointer;
}
&.active a, a:hover {
color: #999;
text-decoration: none;
}
}
}
.fieldsetPreview {
.fieldsetPreviewClose {
font-style: italic;
font-size: 12px;
text-align: center;
}
.fieldsetPreviewImage {
padding: 6px 0px;
img {
height: auto;
max-width: 100%;
vertical-align: middle;
border: 0;
cursor: zoom-in;
}
}
}
}
.settingsWrapper {
&:hover {
caret {
background-color: #333;
}
}
.settingsHeader {
label {
display: inline-block;
}
&:hover {
cursor: pointer;
label {
text-decoration: underline;
}
.caret-right {
border-left-color: #333;
}
}
}
.settings {
padding: 14px;
background-color: #f8f8f8;
overflow: hidden;
.allowedGroups {
.umb-membergrouppicker a {
i {
padding-right: 0;
font-size: inherit;
}
&:hover i {
color: #333;
}
}
}
}
}
}
.archetypeEditor .archetypeEditorControls {
float: none;
position: absolute;
right: 15px;
top: 0;
}
.archetypeConfig .archetypeEditorControls {
float: right;
}
.archetypeEditor form {
margin-left:20px;
.control-label {
padding-top: 0 !important;
.archetypeEditor, .archetypeConfig {
.archetypeEditorControls {
float: right;
}
}
.archetypeEditor .archetypeProperty{
clear: both;
overflow: hidden;
margin-top: 3px;
}
.archetypeEditor .archetypeDeveloperModel
{
font-family: monospace;
width: 98%;
min-height: 100px;
margin-bottom: 10px;
border: 1px solid red;
}
.archetypeEditor .archetypeFieldsetToolbar {
margin-bottom: 10px;
overflow: hidden;
li {
float: left;
padding: 2px 4px;
margin-right: 10px;
border: 1px solid #ddd;
cursor: pointer;
.archetypeEditorControls, .archetypeFieldsetGroups {
i {
cursor: pointer;
&.handle {
cursor: move;
}
&.dimmed {
color: #d9d9d9;
}
}
}
}
.archetypeEditor .archetypeFieldsetHeaderText{
clear:both;
margin-bottom: 3px;
font-size: 12px;
}
.archetypeEditor .archetypeFieldsetFooterText{
clear:both;
margin-bottom: 3px;
font-size: 12px;
}
.archetypeEditor .archetypeFieldsetHelpText{
clear:both;
margin-bottom: 3px;
font-size: 12px;
}
.archetypeConfig {
margin-bottom: 20px;
}
.archetypeConfig ul{
list-style: none;
}
.archetype-headline {
.archetypeConfig li{
background-color: #fff;
}
img {
margin-right: 5px;
}
.archetypeConfig label{
width: 120px;
}
small {
margin-left: 5px;
}
.archetypeConfig .archetypeFieldsetWrapper{
border: 1px solid #ccc;
padding: 10px;
margin-bottom: 10px;
}
a {
float: right;
.archetypeConfig .archetypeFieldsetOption{
margin-bottom: 15px;
input[type=text]{
max-width: 300px;
img {
width: 35px;
}
}
}
}
.archetypeConfig .archetypeDeveloperModel {
font-family: monospace;
width: 88%;
margin: 5px 10px 10px;
height: 130px;
}
.archetypeConfig .archetypePropertiesWrapper {
border: 1px solid #ddd;
padding: 8px;
margin: -40px 10px 10px 140px;
max-width: 475px;
.manual-link {
color: blue;
}
.donate-link {
font-weight: 700;
}
.sponsors {
padding-bottom: 10px;
margin-bottom: 5px;
margin-left: 5px;
display: inline-table;
float: right;
a {
float: none;
}
h4 {
border-bottom: 1px solid #ccc;
}
}
ul {
padding: 0;
margin: 0;
list-style: none;
}
li {
background-color: #fff;
}
label {
width: 120px;
padding-left: 0;
}
.archetypeEditorControls {
float: right;
}
.archetypeFieldsets {
margin-left: 0;
border-top: 5px solid;
padding-top: 5px;
}
.archetypeFieldsetWrapper {
border: 1px solid #ccc;
padding: 10px;
margin-bottom: 10px;
background-color: #eee;
}
.archetypeFieldsetTitle {
cursor: pointer;
overflow: hidden;
}
.archetypeFieldsetOption {
margin-bottom: 15px;
margin-right: 15px;
input[type=text] {
max-width: 190px;
width: auto;
}
select {
max-width: 160px;
max-width: 100%;
width: 100%;
}
}
li:last-child {
margin-bottom: 0;
.archetypeDeveloperModel {
font-family: monospace;
width: 88%;
margin: 5px 10px 10px;
height: 130px;
}
}
.archetypeConfig .archetypeFieldsets {
margin-left: 0;
}
.archetypeOptions {
.btn {
margin-bottom: 5px;
}
.archetypeConfig .archetypeFieldsetTitle {
cursor: pointer;
overflow: hidden;
}
.archetypeConfig .archetypeOptions label{
width: 400px;
}
.archetypeConfig .archetypeAdvancedOptions {
margin-top: 15px;
div {
margin-bottom: 10px;
}
label {
width: 400px;
}
}
.archetypeConfig .archetypeMaxFieldsets{
border: 1px solid #ddd;
width: 40px;
text-align: right;
}
.archetypeConfig .archetypePropertyTitle {
cursor: pointer;
overflow: hidden;
}
.archetypeConfig .archetypePropertyCollapser{
margin-top: 10px;
div {
margin-bottom: 10px;
}
}
.archetypeEditor .archetypeFieldsetError{
border: 1px solid #b94a48;
}
.archetypeEditor .archetypeProperty {
label {
span {
color: #343434;
label {
width: 400px;
}
}
}
.archetypeEditor .archetypePropertyError{
margin-bottom: 5px;
padding-top: 3px;
padding-bottom: 3px;
label {
.archetypePropertiesWrapper {
border: 1px solid #ddd;
padding: 8px;
margin: -40px 10px 10px 140px;
span {
color: #b94a48;
font-weight: bold;
ul {
padding: 0;
margin: 0;
}
li {
padding: 10px;
margin-bottom: 10px;
background-color: #eee;
input[type=text] {
max-width: 100%;
width: 100%;
}
select {
max-width: 100%;
width: 100%;
}
}
li:last-child {
margin-bottom: 0;
}
}
}
.archetypeEditor .archetypeAddButton:hover {
text-decoration: none;
.archetypeAdvancedOptions {
label {
width: 100%;
}
.archetypeAddButtonText {
text-decoration: underline;
input[type=text] {
width: 100%;
}
input[type=checkbox] {
margin-top: 0;
margin-right: 2px;
}
small {
color: #b3b3b3;
}
.archetypeFieldsetGroups {
padding: 0 10px;
margin-bottom: 20px;
ul {
padding: 0;
margin: 0;
margin-top: 15px;
li {
label {
width: 120px;
}
input {
vertical-align: middle;
width: 240px;
}
}
}
}
}
.archetypeMaxFieldsets {
border: 1px solid #ddd;
width: 40px;
text-align: right;
}
.archetypePropertyTitle {
cursor: pointer;
overflow: hidden;
}
.archetypePropertyCollapser {
margin-top: 10px;
div {
margin-bottom: 10px;
margin-right: 15px;
}
}
.archetypeFieldsetCollapser {
margin-top: 15px;
}
.fieldsetIcon {
margin-right: 10px;
}
small {
color: #817f85;
}
}
@@ -324,16 +717,6 @@
background-color: #d0e7f1 !important;
}
.archetypeConfig .archetypeFieldsetCollapser {
margin-top: 15px;
}
.archetypeConfig .fieldsetIcon {
margin-right: 10px;
}
.archetypeEditor .show-validation.ng-invalid .control-group.error .control-label {
span {
color: #343434;
}
}
.archetype-dialog {
margin: 10px;
}
@@ -0,0 +1,46 @@
angular.module('umbraco.resources').factory('archetypePropertyEditorResource', function($q, $http, umbRequestHelper){
return {
getAllDataTypes: function() {
// Hack - grab DataTypes from Tree API, as `dataTypeService.getAll()` isn't implemented yet
return umbRequestHelper.resourcePromise(
$http.get("backoffice/ArchetypeApi/ArchetypeDataType/GetAll"), 'Failed to retrieve datatypes from tree service'
);
},
getAllDataTypesForCache: function() {
return umbRequestHelper.resourcePromise(
$http.get("backoffice/ArchetypeApi/ArchetypeDataType/GetAllDetails"), 'Failed to retrieve datatypes from tree service'
);
},
getDataType: function (guid, useDeepDatatypeLookup, contentTypeAlias, propertyTypeAlias, archetypeAlias, nodeId) {
if(useDeepDatatypeLookup) {
return umbRequestHelper.resourcePromise(
$http.get("backoffice/ArchetypeApi/ArchetypeDataType/GetByGuid?guid=" + guid + "&contentTypeAlias=" + contentTypeAlias + "&propertyTypeAlias=" + propertyTypeAlias + "&archetypeAlias=" + archetypeAlias + "&nodeId=" + nodeId), 'Failed to retrieve datatype'
);
}
else {
return umbRequestHelper.resourcePromise(
$http.get("backoffice/ArchetypeApi/ArchetypeDataType/GetByGuid?guid=" + guid , { cache: true }), 'Failed to retrieve datatype'
);
}
},
getPropertyEditorMapping: function(alias) {
return umbRequestHelper.resourcePromise(
$http.get("backoffice/ArchetypeApi/ArchetypeDataType/GetAllPropertyEditors", { cache: true }), 'Failed to retrieve datatype mappings'
).then(function (data) {
var result = _.find(data, function(d) {
return d.alias === alias;
});
if (result != null)
return result;
return "";
});
},
getDllVersion: function() {
return umbRequestHelper.resourcePromise(
$http.get("backoffice/ArchetypeApi/ArchetypeDataType/GetDllVersion", { cache: true }), 'Failed to retrieve dll version'
);
}
}
});
-29
View File
@@ -1,29 +0,0 @@
angular.module('umbraco.resources').factory('archetypePropertyEditorResource', function($q, $http, umbRequestHelper){
return {
getAllDataTypes: function() {
// Hack - grab DataTypes from Tree API, as `dataTypeService.getAll()` isn't implemented yet
return umbRequestHelper.resourcePromise(
$http.get("/umbraco/backoffice/ArchetypeApi/ArchetypeDataType/GetAll"), 'Failed to retrieve datatypes from tree service'
);
},
getDataType: function(guid) {
return umbRequestHelper.resourcePromise(
$http.get("/umbraco/backoffice/ArchetypeApi/ArchetypeDataType/GetByGuid?guid=" + guid), 'Failed to retrieve datatype'
);
},
getPropertyEditorMapping: function(alias) {
return umbRequestHelper.resourcePromise(
$http.get("/umbraco/backoffice/ArchetypeApi/ArchetypeDataType/GetAllPropertyEditors"), 'Failed to retrieve datatype mappings'
).then(function (data) {
var result = _.find(data, function(d) {
return d.alias === alias;
});
if (result != null)
return result;
return "";
});
}
}
});
+87
View File
@@ -0,0 +1,87 @@
angular.module('umbraco.services').factory('archetypeCacheService', function (archetypePropertyEditorResource, $q, entityResource) {
//private
var entityCache = [];
var datatypeCache = [];
return {
initialize: function() {
return archetypePropertyEditorResource.getAllDataTypesForCache().then(function(data) {
_.each(data, function(datatype) {
datatypeCache[datatype.dataTypeGuid] = datatype;
});
});
},
getDataTypeFromCache: function(guid) {
return datatypeCache[guid];
},
getDatatypeByGuid: function(guid) {
var cachedDatatype = this.getDataTypeFromCache(guid);
if(cachedDatatype) {
return cachedDatatype;
}
return null;
},
getEntityById: function(id, type) {
var deferred = $q.defer();
//console.log(entityCache);
var cachedEntity = entityCache[id];
if(cachedEntity) {
//console.log("Found ID " + id);
deferred.resolve(cachedEntity);
return deferred.promise;
}
//go get it from server
entityResource.getById(id, type).then(function(entity) {
entityCache[id] = entity;
//console.log("entity ID is now resolved into cache...");
//console.log(entityCache);
deferred.resolve(entity);
});
return deferred.promise;
},
//perhaps this should return a promise?
getEntityByUmbracoId: function(udi, type) {
var deferred = $q.defer();
var cachedEntity = entityCache[udi];
if(cachedEntity) {
//console.log("Found UDI " + udi);
deferred.resolve(cachedEntity);
return deferred.promise;
}
//go get it from server
entityResource.getByIds([udi], type).then(function (entities) {
// prevent infinite lookups with a default entity
var entity = entities.length > 0 ? entities[0] : { udi: udi, name: "" };
entityCache[udi] = entity;
//console.log("entity UDI is now resolved into cache...");
//console.log(entityCache);
deferred.resolve(entity);
});
return deferred.promise;
}
}
});
@@ -0,0 +1,19 @@
angular.module('umbraco.services').factory('archetypeGlobalConfigService', function ($q, $http, umbRequestHelper) {
return {
globalSettings: function () {
return umbRequestHelper.resourcePromise(
$http.get("backoffice/ArchetypeApi/ArchetypeDataType/globalSettings"), 'Failed to get whether or not we are checking for updates!'
);
},
setCheckForUpdates: function (isChecking) {
return umbRequestHelper.resourcePromise(
$http.post("backoffice/ArchetypeApi/ArchetypeDataType/SetCheckForUpdates", isChecking), 'Failed to update check status!'
);
},
checkForUpdates: function () {
return umbRequestHelper.resourcePromise(
$http.post("backoffice/ArchetypeApi/ArchetypeDataType/checkForUpdates", { }), 'Failed to check for updates!'
);
}
}
});

Some files were not shown because too many files have changed in this diff Show More