Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

force user input in autocomplete #176

Merged
merged 4 commits into from
May 2, 2019
Merged

Conversation

loonix
Copy link
Contributor

@loonix loonix commented May 2, 2019

Fixes #174

@ghiscoding
Copy link
Owner

Thanks for the PR, however if this option is really only used with the Autocomplete Editor, I would rather move it into the editorOptions.

I try to keep, as much as possible, only options that can be used by all Editors inside the columnEditor.interface.ts, else the editorOptions is a better fit even though that property is generic.

@loonix
Copy link
Contributor Author

loonix commented May 2, 2019

That sounds reasonable, I changed it to the editorOptions and took it out of the columnEditor. I removed the type not sure if you want to add it on the multipleSelectOption.interface.ts

@ghiscoding
Copy link
Owner

If you want the intellisense to work, could maybe change the editorOptions to the following

editorOptions?: MultipleSelectOption | forceUserInput?: boolean | any;

I know that keeping the any as a type is not too good, it kind of undo the intellisense feature, maybe someday I should add all possible options for each Editors but it's kinda long to do that. For example the Date Editor uses Flatpickr and so I would have to go and all every possible options into a separate interface and then modify the editorOptions like so

editorOptions?: MultipleSelectOption | FlatpickrOptions | AutoCompleteOptions;

but that is kinda long, I don't have time to do that. Unless you or anyone else have a better way of doing it with TypeScript

@loonix
Copy link
Contributor Author

loonix commented May 2, 2019

I am happy to give a hand on that, and that would be a lot better since we can track the options straight away (maybe on a next pull request)

What about if you create a project and add tasks there so contributors know what can be done to help?

@ghiscoding
Copy link
Owner

Sure, I created the version 2.x - Project and added some tasks there. I didn't use much before, so if you have better ways of displaying that, let me know, I think it should be enough to start. I can reference a PR to the task when it opens up

@@ -69,7 +71,7 @@ export class AutoCompleteEditor implements Editor {
const title = this.columnEditor && this.columnEditor.title || '';
this.labelName = this.customStructure && this.customStructure.label || 'label';
this.valueName = this.customStructure && this.customStructure.value || 'value';

this.forceUserInput = this.columnEditor && this.columnEditor.editorOptions && this.columnEditor.editorOptions.forceUserInput ? this.columnEditor.editorOptions.forceUserInput : false;
Copy link
Owner

Choose a reason for hiding this comment

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

To simplify this line, you could maybe use a Getter, for example see this Getter. It's just a suggestion, I could also accept the code without it too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, makes sense to refactor it :)

Copy link
Owner

Choose a reason for hiding this comment

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

Oh man I'm really sorry, I was not clear in my comment, can you change it to the following

get editorOptions() {
    return this.columnEditor && this.columnEditor.editorOptions || {};
  }

then you can call your boolean values (and any other editor options) like so

serializeValue() {
  if (this.editorOptions.forceUserInput) {
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem at all (never used getter before) made a new pr, let me know if it is what you have in mind. Thanks

init(): void {
const columnId = this.columnDef && this.columnDef.id;
const placeholder = this.columnEditor && this.columnEditor.placeholder || '';
const title = this.columnEditor && this.columnEditor.title || '';
this.labelName = this.customStructure && this.customStructure.label || 'label';
this.valueName = this.customStructure && this.customStructure.value || 'value';

this.forceUserInput = this.forceUserInputChecker;
Copy link
Owner

Choose a reason for hiding this comment

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

do you really need this line after using the Getter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not after the changes you requested, removed it.

@ghiscoding
Copy link
Owner

Thanks looks good now :)

@ghiscoding
Copy link
Owner

Will merge now, I was trying to fix the new Circle-CI and Codecov for unit tests coverage. I finally found the correct config. Sweet, I now have full CI (continuous integration) in the project :)

@ghiscoding ghiscoding merged commit 2acf2c7 into ghiscoding:master May 2, 2019
@ghiscoding
Copy link
Owner

@loonix
Sorry for the delay, as you have noticed I wanted to wait for the other PR to be merged.
Your update is now available under latest version 2.6.0 on NPM

@loonix
Copy link
Contributor Author

loonix commented May 11, 2019

No problem, many thanks for telling me. Is there a slack chanel or irc chanel you use to go?

@ghiscoding
Copy link
Owner

I don't really use Slack and there's no channel or any kind since I'm alone on this lol

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

Successfully merging this pull request may close these issues.

Autocomplete accept value that is not on the list
2 participants