Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Angular fields #374

Merged
merged 1 commit into from
Oct 14, 2019
Merged

Custom Angular fields #374

merged 1 commit into from
Oct 14, 2019

Conversation

merobal
Copy link
Collaborator

@merobal merobal commented Sep 25, 2019

Helper classes to create and register custom fields based on any Angular component implemented as field input (with value Input and valueChange Output).

It creates a webcomponent (Angular Element), then creates a custom field class using that webcomponent as the input element.

Usage example:

import { Injector } from '@angular/core';
import { FormioCustomComponentInfo, registerCustomFormioComponent } from 'angular-formio';
import { DatepickerComponent } from './datepicker.component';
import { datePickerEditForm } from './edit-form';

const COMPONENT_OPTIONS: FormioCustomComponentInfo = {
  type: 'mydatepicker',
  selector: 'my-datepicker',
  title: 'Datepicker',
  group: 'basic',
  icon: 'fa fa-calendar',
  editForm: datePickerEditForm,
};

export function registerDatepickerComponent(injector: Injector) {
  registerCustomFormioComponent(COMPONENT_OPTIONS, DatepickerComponent, injector);
}

And call the registerDatepickerComponent inside a constructor of any NgModule with the Injector.

I will update the demo app to provide more live examples once it's merged and released.

@travist
Copy link
Member

travist commented Sep 25, 2019

This is great work! I will be releasing 4.2.0 soon, so this may need to be rebased. I will also need some time to test out what is going on with this change, but from what I can tell, this is an amazing contribution!

@merobal merobal force-pushed the codingsans branch 4 times, most recently from acf466f to 63a7b14 Compare October 3, 2019 13:38
@@ -62,6 +63,7 @@ export class FormioBaseComponent implements OnInit, OnChanges, OnDestroy {
private submitting = false;

constructor(
public customTags: CustomTagsService,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this the last component and also optional so we can preserve reverse compatibility? Example: The Angular Material library would break with this change @ https://github.com/formio/angular-material-formio/blob/master/projects/angular-material-formio/src/lib/formio.component.ts#L34

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, just updated

@merobal
Copy link
Collaborator Author

merobal commented Oct 10, 2019

@travist I created a quick demo, you can check here: https://angular-formio-custom-demo.netlify.com/
I added a Rating component based on https://ng-bootstrap.github.io/#/components/rating/examples

You can check the code here as well: merobal/angular-formio-custom-demo@8901005

That commit shows all the necessary polyfills and setup.

@travist
Copy link
Member

travist commented Oct 10, 2019

This is great and thank you! I am currently doing a few patch releases (some more coming this week) and then once I get through those, I will be including this in this library. This really is a fantastic addition to this library!

@travist travist merged commit 03f3f80 into formio:master Oct 14, 2019
@travist
Copy link
Member

travist commented Oct 14, 2019

Thanks again for this contribution! Do you have access to contribute to the Wiki of this library? That would be a great place to write some documentation about it.

@travist
Copy link
Member

travist commented Oct 14, 2019

This is currently released in 4.3.0-beta.1

@merobal
Copy link
Collaborator Author

merobal commented Oct 14, 2019

Only contributors can edit the wiki, if you add me I add some docs about this feature

@merobal
Copy link
Collaborator Author

merobal commented Oct 22, 2019

@travist could you please create a new beta-2 version where you set the formiojs to the latest version?

Also would it be okay if I write the docs in markdown for the wiki and I send to you via email?

@travist
Copy link
Member

travist commented Oct 22, 2019

@merobal I added you to the contributors list so you should be able to write some documentation over this now.

I will also release a new version with latest renderer. We are working on a new build with many bug fixes (should get released by tomorrow) so I will forge a new version of this library when that is done.

@merobal
Copy link
Collaborator Author

merobal commented Oct 22, 2019

Thanks!

@merobal
Copy link
Collaborator Author

merobal commented Nov 6, 2019

@travist
Copy link
Member

travist commented Dec 23, 2019

@merobal I am pretty sure this broke the build for those on Angular 7.

#412

I am going to do some investigation, but it seems that those who are on the previous release (before we pulled this in) worked in Angular 7, but after this commit, no longer works. I would hate to have to revert (or fork) this repo, but we have many people still on Angular 7 and unable to upgrade. Any suggestions on what was included that would have broken Angular 7?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants