angular-schema-form icon indicating copy to clipboard operation
angular-schema-form copied to clipboard

adding raw template to decorator

Open Traksewt opened this issue 9 years ago • 5 comments

Description

Currently setting the template for a custom decorator requires using the template cache, and you cannot pass in a raw template string. There is some code inside the decorator provider to support it, but it is not exposed, as it does not work.

When manually setting the decorator to have type equals to template, the builder cannot find the raw template. This is because it is looking for the 'template' field on the wrong variable, checking the form instead of the 'field'.

To test out using a raw template, you can try

schemaFormDecoratorsProvider.decorator('bootstrapDecorator')['myCustomDecorator'].type = 'template';

Fixes Related issues

  • This doesn't expose raw templates to the decorator helper methods, however, it does get rid of the bugs so it can be exposed in the future.

Checklist

  • [x] I have read and understand the CONTRIBUTIONS.md file
  • [x] I have searched for and linked related issues
  • [x] I have created test cases to ensure quick resolution of the PR is easier
  • [x] I am NOT targeting main branch
  • [x] I did NOT include the dist folder in my PR

@json-schema-form/angular-schema-form-lead

Traksewt avatar Dec 02 '16 02:12 Traksewt

@Traksewt thanks for your PR sorry for the delayed response, I was in the middle of the separated core changes and then holidays, would you be able to update to the latest version and reapply your changes to the renamed files? Would love to accept your efforts :)

src/services/builder.js -> src/services/sf-builder.provider.js test/services/decorators-test.js -> src/services/schema-form-decorators.provider.spec.js

Anthropic avatar Jan 19 '17 23:01 Anthropic

@Anthropic ok no problem. rebased.

Traksewt avatar Jan 24 '17 01:01 Traksewt

Didn't realise I could change it myself within your commit, how cool :)

Oh but then your test fails... hmmm...

Anthropic avatar Jan 24 '17 11:01 Anthropic

@Traksewt any ideas?

Anthropic avatar Apr 20 '17 13:04 Anthropic

The tests are failing because the decorator is trying to load the template remotely as a url, but the template is a string.

scottux avatar Aug 18 '18 12:08 scottux