Coder Social home page Coder Social logo

qontu / ngx-inline-editor Goto Github PK

View Code? Open in Web Editor NEW
164.0 25.0 90.0 8.12 MB

Native UI Inline-editor Angular (4.0+) component

Home Page: https://qontu.github.io/ngx-inline-editor

License: MIT License

TypeScript 97.68% CSS 1.04% HTML 1.28%
angular ng2-inline-editor editor inline-editing ngx-inline-editor angular2 angular4

ngx-inline-editor's Introduction

Native UI Inline-editor Angular (version 4+) component (demo)

Follow me twitter to be notified about new releases.

ngx-inline-editor is a library of Angular (version 4+) that allows you to create editable elements. Such technique is also known as click-to-edit or edit-in-place. It is based on ideas of angular-xeditable which is developed in AngularJS.

Version 0.1.0

Dependencies

Basically it does not depend on any libraries except Angular4 itself. For themes you may need to include Twitter Bootstrap CSS.

Angular 4+ Version

Angular 4 is now stable. Therefore, if encountering errors using this lib, ensure your version of Angular is compatible. The current version used to develop this lib is angular4 ^4.0.0.

Controls & Features

  • text
  • textarea
  • select
  • checkbox
  • radio
  • date
  • time
  • datetime
  • html5 inputs
    • pattern
    • number
    • range
  • typeahead
  • ui-select
  • complex form
  • editable row
  • editable column
  • editable table
  • themes

Quick start

  1. A recommended way to install ngx-inline-editor is through npm package manager using the following command:

npm i @qontu/ngx-inline-editor --save

  1. Include the basic theme or configure your own styles which are in the following path:

dist/themes/bootstrap.css

  1. Include Twitter Bootstrap and FontAwesome in your project.

Usage

Angular (4+) and later

Import InlineEditorModule into your app's modules:

import {InlineEditorModule} from '@qontu/ngx-inline-editor';

@NgModule({
  imports: [
    InlineEditorModule
  ]
})

This makes all the @qontu/ngx-inline-editor components available for use in your app components.

Simple Example

You can find a complete example here

import {Component} from '@angular/core';

@Component({
    selector: 'my-component',
    template: `
    <div>
        <inline-editor type="text" [(ngModel)]="editableText" (onSave)="saveEditable($event)" name="editableText1" size="8"></inline-editor>
    </div>
    <div>
        <inline-editor type="password" [(ngModel)]="editablePassword" (onSave)="saveEditable($event)"></inline-editor>
    </div>
    <div>
        <inline-editor type="textarea" [(ngModel)]="editableTextArea" (onSave)="saveEditable($event)"> </inline-editor>
    </div>
    <div>
        <inline-editor type="select" [(ngModel)]="editableSelect" (onSave)="saveEditable($event)" [options]="editableSelectOptions"
        value="valor"></inline-editor>
  </div>`
})
export class MyComponent {
  title = 'My component!';

  editableText = 'myText';
  editablePassword = 'myPassword';
  editableTextArea = 'Text in text area';
  editableSelect = 2;
  editableSelectOptions =[
    {value: 1, text: 'status1'},
    {value: 2, text: 'status2'},
    {value: 3, text: 'status3'},
    {value: 4, text: 'status4'}
  ];

  saveEditable(value) {
    //call to http service
    console.log('http.service: ' + value);
  }

API

InlineEditorDirectives

Text
 <inline-editor
        type="text"
        [(ngModel)]="editableText"
        (onSave)="saveEditable($event)"
        name="editableText1"
        size="8"
        disabled="true"
        min="1"
        max="8"
        pattern="^[a-zA-Z]{1,3}"
        (onError)="myHandleError()"></inline-editor>
  • type [string] Specifies the type <input> element to display.
  • onSave [event handler] The expression specified will be invoked whenever the form is save via a click on save button. The $event argument will be the value return of the input send.
  • onError [event handler] The expression specified will be invoked whenever the form is save via a click on save button and an error is provoked (example: the value is not between min and max).
  • name [string] Defines the name of an <input> element. Default is undefined.
  • size [number] Defines the width, in characters, of an <input> element. Default is 8.
  • disabled [boolean] If set to true, a disabled input element is unusable and un-clickable. Default is false.
  • min [number] the min attribute specifies the minimum value for an <input> element. Default is 1.
  • max [number] the max attribute specifies the maximum value for an <input> element. Default is Infinity.
Password
 <inline-editor
        type="password"
        [(ngModel)]="editablePassword"
        (onSave)="saveEditable($event)"
        name="editablePassword"
        size="8"
        disabled="true"
        min="1"
        max="8"
        (onError)="myHandleError"></inline-editor>
  • type [string] Specifies the type <input> element to display.
  • onSave [event handler] The expression specified will be invoked whenever the form is save via a click on save button. The $event argument will be the value return of the input send.
  • onError [event handler] The expression specified will be invoked whenever the form is save via a click on save button and an error is provoked (example: the value is not between min and max).
  • name [string] Defines the name of an <input> element. Default is undefined.
  • size [number] Defines the width, in characters, of an <input> element. Default is 8.
  • disabled [boolean] If set to true, a disabled input element is unusable and un-clickable. Default is false.
  • min [number] the min attribute specifies the minimum value for an <input> element. Default is 1.
  • max [number] the max attribute specifies the maximum value for an <input> element. Default is Infinity.
TextArea
 <inline-editor
        type="textarea"
        [(ngModel)]="editableTextArea"
        (onSave)="saveEditable($event)"
        name="editableTextArea"
        size="8"
        disabled="true"
        cols="50"
        rows="4"
        min="1"
        max="8"
        (onError)="myHandleError"></inline-editor>
  • type [string] Specifies the type <input> element to display.
  • onSave [event handler] The expression specified will be invoked whenever the form is save via a click on save button. The $event argument will be the value return of the input send.
  • onError [event handler] The expression specified will be invoked whenever the form is save via a click on save button and an error is provoked (example: the value is not between min and max).
  • name [string] Defines the name of an <input> element. Default is undefined.
  • size [number] Defines the width, in characters, of an <input> element. Default is 8.
  • disabled [boolean] If set to true, a disabled input element is unusable and un-clickable. Default is false.
  • cols [number] Specifies the visible width of a text area. Default is 50.
  • rows [number] Specifies the visible height of a text area. Default is 4.
  • min [number] the min attribute specifies the minimum value for an <input> element. Default is 1.
  • max [number] the max attribute specifies the maximum value for an <input> element. Default is Infinity.
Select
Basic example
<inline-editor
        type="select"
        [(ngModel)]="editableSelect"
        (onSave)="saveEditable($event)"
        name="editableSelect"
        disabled="false"
        [options]="editableSelectOptions"></inline-editor>
  • type [string] Specifies the type <input> element to display.
  • onSave [event handler] The expression specified will be invoked whenever the form is save via a click on save button. The $event argument will be the value return of the input send.
  • name [string] Defines the name of an <input> element. Default is undefined.
  • disabled [boolean] If set to true, a disabled input element is unusable and un-clickable. Default is false.
  • options [Array<optionItem> | Object:{ data: Array<optionItem, value:string, text: string }] Array of items from which to select. Should be an array of objects with value and text properties. Is possible to configure key-value parameters using an object that specifies these fields and data.

Typescript code:

  editableSelect = 2;
  editableSelectOptions =[
    {value: 1, text: 'status1'},
    {value: 2, text: 'status2'},
    {value: 3, text: 'status3'},
    {value: 4, text: 'status4'}
  ];

  saveEditable(value) {
    //call to http server
    console.log('http.server: ' + value);

  }
Parameter's configuration example
  • editableSelect [number] Specifies the default's value of the select.
  • editableSelectOptions [Array<optionItem> | Object: { data: Array<optionItem, value:string, text: string }] Specifies the array of items from which to select. Should be an array of objects with value and text properties. Is possible to configure key-value parameters using an object that specifies these fields and data.

Typescript code:

  editableSelect = 2;
  editableSelectOptionsConfiguration = {
    data: [
      { id: 1, field: 'status1' },
      { id: 2, field: 'status2' },
      { id: 3, field: 'status3' },
      { id: 4, field: 'status4' }
    ],
    value: 'id',
    text: 'field'
  }

  saveEditable(value) {
    //call to http server
    console.log('http.server: ' + value);

  }
Children example

Is possible to configure sublevels/children to generate the select using an array of objects called children.

Typescript code:

 editableSelectOptionsTwoLevelsDefault = 1;
  editableSelectOptionsTwoLevelsConfiguration = {
    data: [
      {
        id: 1, field: 'status1',
        children: [
          { id: 5, field: 'status1.1' },
          { id: 6, field: 'status1.2' }
        ]
      },
      { id: 2, field: 'status2' },
      { id: 3, field: 'status3' },
      {
        id: 4, field: 'status4',
        children: [{ id: 7, field: 'status4.1' }]
      }
    ],
    value: 'id',
    text: 'field'
  }

Version 0.1.0-optGroup

Empty components

  <inline-editor
  type="text"
  ngModel
  empty="My custom message"
  (onSave)="saveEditable($event)"
  (onError)="handleError"
  name="editableText1"
  size="8"
  min="3"
  max="5"></inline-editor>

  <inline-editor type="select"
                [(ngModel)]="editableSelectDoesntExist"
                (onSave)="saveEditable($event)"
                [options]="editableSelectOptionsConfiguration"></inline-editor>
  • empty [string] Specifies the default message to display if there are not ngModel for the component. If the type is select then the default selected element is the first element of the options array.

Style/Theme

The inline-editor has the following basic theme which you can find in dist/themes/bootstrap.css:

a.c-inline-editor {
  text-decoration: none;
  color: #428bca;
  border-bottom: dashed 1px #428bca;
  cursor: pointer;
  line-height: 2;
  margin-right: 5px;
  margin-left: 5px;
}
.c-inline-editor.editable-empty,
.c-inline-editor.editable-empty:hover,
.c-inline-editor.editable-empty:focus,
.c-inline-editor.a.editable-empty,
.c-inline-editor.a.editable-empty:hover,
.c-inline-editor.a.editable-empty:focus {
  font-style: italic;
  color: #DD1144;
  text-decoration: none;
}

.c-inline-editor.inlineEditForm {
  display: inline-block;
  white-space: nowrap;
  margin: 0;
}

#inlineEditWrapper {
  display: inline-block;
}

.c-inline-editor.inlineEditForm input,
.c-inline-editor.select {
  width: auto;
  display: inline;
}

.c-inline-editor.inline-editor-button-group {
  display: inline-block;
}

.c-inline-editor.editInvalid {
  color: #a94442;
  margin-bottom: 0;
}

.c-inline-editor.error {
  border-color: #a94442;
}

[hidden].c-inline-editor {
  display: none;
}

Integration with other ngx-libraries

ngx-data-table

Example using angular2-data-table (demo) Version 0.1.0-angular2-data-table

Troubleshooting

Please follow this guidelines when reporting bugs and feature requests:

  1. Use GitHub Issues board to report bugs and feature requests (not our email address)
  2. Please always write steps to reproduce the error. That way we can focus on fixing the bug, not scratching our heads trying to reproduce it.

Thanks for understanding!

Development

  1. To generate all *.js, *.js.map and *.d.ts files:

    npm run build

  2. To debug :

    npm run build:watch

Authors

Carlos Caballero - https://github.com/caballerog

Antonio Villena - https://github.com/xxxtonixxx

License

The MIT License (See the LICENSE file for the full text) -

ngx-inline-editor's People

Contributors

ahinni avatar caballerog avatar faizanu94 avatar gktim avatar igncp avatar jesussegado avatar jmorganmartin avatar manuelmolina97 avatar npmcdn-to-unpkg-bot avatar scieon avatar tonivj5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ngx-inline-editor's Issues

Template parse error, 'ng-template' is not a known element

Angular 2.4.6
By installing the plugin and importing it in app module I get the following console error:

"Error: Template parse errors:
"let-" is only supported on template elements. ("lect #inputRef class="form-control" [(ngModel)]="context.value">
                <ng-template ngFor [ERROR ->]let-item [ngForOf]="context.options.data">
                    <optgroup *ngIf="item.children" [label"): InputSelectComponent@1:35
'ng-template' is not a known element:
1. If 'ng-template' is an Angular component, then verify that it is part of this module.
2. If 'ng-template' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("<select #inputRef class="form-control" [(ngModel)]="context.value">
                [ERROR ->]<ng-template ngFor let-item [ngForOf]="context.options.data">
                    <optgroup *ngIf="it"): InputSelectComponent@1:16
    at SyntaxError.ZoneAwareError (http://localhost:3000/polyfills.dll.js:4732:33)
    at SyntaxError.BaseError [as constructor] (http://localhost:3000/vendor.dll.js:72174:16)
    at new SyntaxError (http://localhost:3000/vendor.dll.js:6320:16)
    at TemplateParser.parse (http://localhost:3000/vendor.dll.js:19406:19)
    at JitCompiler._compileTemplate (http://localhost:3000/vendor.dll.js:52671:68)
    at http://localhost:3000/vendor.dll.js:52554:62
    at Set.forEach (native)
    at JitCompiler._compileComponents (http://localhost:3000/vendor.dll.js:52554:19)
    at createResult (http://localhost:3000/vendor.dll.js:52436:19)
    at ZoneDelegate.invoke (http://localhost:3000/polyfills.dll.js:4163:26)
    at Zone.run (http://localhost:3000/polyfills.dll.js:4034:43)
    at http://localhost:3000/polyfills.dll.js:4456:57
    at ZoneDelegate.invokeTask (http://localhost:3000/polyfills.dll.js:4196:35)
    at Zone.runTask (http://localhost:3000/polyfills.dll.js:4072:47)
    at drainMicroTaskQueue (http://localhost:3000/polyfills.dll.js:4354:35)
    at HTMLDocument.ZoneTask.invoke (http://localhost:3000/polyfills.dll.js:4270:25)"

According to primefaces/primeng#2333 ng-template is Angular4 only.

Any fix for this?

ng build error with AOT compiler

I am getting below error in ng build --prod.

ERROR in /Volumes/Working/projects/test/src/$$_gendir/node_modules/ng2-inline-editor/dist/inline-editor.co
mponent.ngfactory.ts (334,18): Property 'container' is private and only accessible within class 'InlineEditorCo
mponent'.
/Volumes/Working/projects/test/src/$$_gendir/node_modules/ng2-inline-editor/dist/inline-editor.component.n
gfactory.ts (380,42): Property 'editing' is private and only accessible within class 'InlineEditorComponent'.
/Volumes/Working/projects/test/src/$$_gendir/node_modules/ng2-inline-editor/dist/inline-editor.component.n
gfactory.ts (390,47): Property 'editing' is private and only accessible within class 'InlineEditorComponent'.

ERROR in /Volumes/Working/projects/test/src/$$_gendir/node_modules/ng2-inline-editor/dist/inputs/input-tex
tarea.component.ngfactory.ts (152,48): Property 'rows' does not exist on type 'InputConfig'.
/Volumes/Working/projects/test/src/$$_gendir/node_modules/ng2-inline-editor/dist/inputs/input-textarea.com
ponent.ngfactory.ts (157,49): Property 'cols' does not exist on type 'InputConfig'.

Unexpected value 'InlineEditorModule' imported by the module 'AppModule'

Anybody had this problem?

Unexpected value 'InlineEditorModule' imported by the module 'AppModule'.

in my app.module.ts:
`import { InlineEditorModule } from 'ng2-inline-editor';

...
@NgModule({
imports: [InlineEditorModule, ...],
declarations: [...]
`

in my template:
<inline-editor type="text" [(ngModel)]="editableText" (onSave)="saveEditable($event)" name="editableText1" size="8"></inline-editor>

I installed using npm:

npm i ng2-inline-editor --save

Did I miss anything?

PostInstall issue with typings

Hello,
Trying to install this on a project with Angular 2.1.0 with CLI v1.0.0-beta.19-3 and I am getting an error related to the typings install in the postinstall step.

npm install --save ng2-inline-editor

> [email protected] postinstall /Users/devakone/wutang/node_modules/ng2-inline-editor
> typings install

sh: typings: command not found
npm WARN @ngtools/[email protected] requires a peer of @angular/[email protected] but none was installed.
npm WARN @ngtools/[email protected] requires a peer of @angular/[email protected] but none was installed.
npm ERR! Darwin 16.1.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--save" "ng2-inline-editor"
npm ERR! node v7.1.0
npm ERR! npm  v3.10.9
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn

npm ERR! [email protected] postinstall: `typings install`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'typings install'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ng2-inline-editor package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     typings install
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs ng2-inline-editor
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls ng2-inline-editor
npm ERR! There is likely additional logging output above.

Thanks

ERROR in InlineEditorModule is not an NgModule

I can't past the basic example. I run ng init using Angular CLI, then npm i ng2-inline-editor --save. Add import {InlineEditorModule} from 'ng2-inline-editor'; to app module then in the same file add InlineEditorModule to the imports array and ng serve that up and I get that ERROR in InlineEditorModule is not an NgModule error. I saw your note on various versions of Angular2 ruining compatibility and so I copied your package.json from one of your examples, re-ran the ng serve and got the same error.

Any ideas?

The basic demo fails to compile

Hi,

I did a clean npm i in the basic demo, then a npm start, which uses ng serve and it is throwing some errors, complaining about the format of the config file angular-cli.json. I tried with a similar configuration as the other demo, but it still fails. I am using node 6.3.0, and the other dependencies should come from the package.json. Can you build it with a clean npm i?

Thanks!

fnErrorLength issue with minification in angular-cli

Hello,
Great module you got here, I ran into some edge cases that I think are worth looking into.

Let's say I define my input as:

<inline-editor empty="Add Text" #intro type="textarea" [(ngModel)]="intro.text" (onSave)="saveText($event)" (onEdit)="editText($event)" (onCancel)="cancel($event)" min="5" [fnErrorLength]="onTextMissing"> </inline-editor>

And the onTextMissing is defined in the component like this:

onTextMissing = () => { this.isTextMissing = true; }

I am using the closure because i need to reference a binding in my component. This renders the following HTML
<inline-editor _ngcontent-ljw-49="" empty="Add Text" min="5" type="textarea" _nghost-ljw-43="" ng-reflect-empty="Add text " ng-reflect-type="textarea" ng-reflect-min="5" ng-reflect-fn-error-length="function () { _this.isTextMissing = true; }" class="ng-untouched ng-pristine ng-valid">

This works fine in dev mode, but when it builds for production the ng-reflect-fn-error-length attribute never makes it to the HTML. I am using the angular-cli so it might be something in the webpack build.

How should the public API be? We want your feedback

With the last PR (#57), the public API is going to change and it would be good opinions and way of to do this.

At the moment, the public API is something like this:
All events return an ExternalEvent (exported as InlineEvent) ->

{ 
  event?: Event, 
  state: { value: any, empty: boolean,  editing: boolean, disabled: boolean } // it's an InlineState
}

An state is the state of input when this one changed (the new state), for example: if I click an input, its state will change from editing: false to editing: true, and if I type 'a', its state will change from value: '' to value: 'a'. These states are in hot, until I do click on save, this changes will not reflect in the model (ngModel) and I will receive it using the events ((onChange)="todoSomething($event)", etc.).

  • Events bindable
    • onSave
    • onEdit
    • onCancel
    • onError // This one returns an InlineError | InlineError[] -> { type: string, message: string }
    • onChange
    • onKeyPress
    • onEnter
    • onEscape
    • onFocus
    • onBlur
  • Public methods (API) (with these methods you can change the state of input)
    • save( { event: Event, state: InlineState }: ExternalEvent )
    • saveAndClose( { event: Event, state: InlineState }: ExternalEvent )
    • edit( { editing: boolean, doFocus: boolean } )
    • cancel( { event: Event, state: InlineState }: ExternalEvent )
    • getHotState(): InlineState // This returns state from input (no saved)

Are the methods user friendly? is this the correct approach? Please, give us your feedback ๐Ÿ‘

AOT mode is not supported

I use AOT with systemjs and I have some troubles with your component.

Basically I used the following procedure to be able to use it in aot mode:
yuyang041060120/angular2-ui-switch#2
... and got it working to until the following error:

Error at [...]/node_modules/ng2-inline-editor/dist/inline-editor.component.ngfactory.ts:1434:46: Property 'editing' is private and only accessible within class 'InlineEditorComponent'.

Witch basically means you're probably accessing a private property of your component from inside the html file... My guess is that you just need to use a getter instead.

Thx

Implementing forms

Hi im new to angular2 are you planing of implementing x-editable forms.If not can you give me some hints what is the best way to do it in angular2

Input text size should be "0"

At the moment the default value for input text size is 8, this is a problem when you wish use Bootstrap or any framework to design your component.

If the default value is -1 or 0, the component use the class assign to define the size of the input. Futhermore, in the configuration object you would define your own size in the case that you need define this value.

Error in validation of form

When a input element is validate using (onError) for example, in the form the change is avoid, ie, the component work correctly but sadly, in the model (ngModel) reference the change is done.

So, this is a bug in the behaviour of the component.

Support for a placeholder text which is not the default text when editing

When a field is empty you might want to draw attention to it by adding a descriptive placeholder text, which when clicked should open the inline editor.

If I use the empty attribute for this purpose, the placeholder text is also the default value, which is undesired sometimes. Any suggestions?

https://github.com/Caballerog/ng2-inline-editor#empty-components

Example

        <inline-editor
          type="text"
          empty="No name set"
          [(ngModel)]="user.name"
          (onSave)="updateName($event)"></inline-editor>

ng2-inline-editor
ng-inline-editor-editing

Testing

I should to do test using Jasmine to test the logic!

custom button size

Hi can i get control to change button property such as padding ,width etc???????

Custom Display Templates

Hi there, great library! It'd be nice if I could add some custom formatting/HTML when the components are in display mode.

For example, next to the username, I would want to display a user icon, but not in editing mode.

<inline-editor type="text" [(ngModel)]="account.username">
   <i class="fa fa-user"></i>
   {{ account.userName }}
</inline-editor>

Required is not being checked

Running this piece of code:

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  template: `
  <h1> {{editableText}} </h1>
    <div>
        <inline-editor type="text" [required]="true" [(ngModel)]="editableText" (onSave)="saveEditable($event)"></inline-editor>
    </div>
  `
})
export class AppComponent {
  editableText = 'myText';

  saveEditable(event) {
    console.log('http.service: ', event);
  }
}

If element's text is empty when submitting, it does not trigger any error.

Support for reactive forms

I noticed the use of ngModel what about reactive forms ? is this someting that is planned or already supported ?

Importing the ngModel form module is not someting i would want to do.

To make this possible we would need two templates one that already exists and uses ngModel and a second one that use [value]="value" (input)="value = $event.target.value" instead of ngModel, maybe a second component called someting like "ReactiveInlineEditorComponent" that extends InlineEditorComponent but has diffrent template ?

Here is an example of how it could look like modified the source:
some minor changes i replaced ' with " you can revert that if you dont like it the other one is
using templateUrl instead of template as we need more then one template and it would be to much info
in one file if we would use a second variable for it.

ng2-inline-editor.zip

Control visibility of the input

The editing variable is private in the component, but in case I want to control validation of the input there is no way to do so atm.
Adding a public setEditMod(mode:boolean) variable would help transfer control of the visibility of the editor to the calling component.

Roadmap to 1.0

  • Change name to ngx-inline-editor or ng-inline-editor and move it to @qontu org
  • Rewrite README.md [WIP]
  • Create documentation into the source code (using compodoc) [WIP]
  • Use semver
  • Create new examples using the new features and possibilities [WIP]
  • Update gh-pages with documentation and examples [WIP]
  • To do test to the project [WIP]

Controls & Features

  • text
  • textarea
  • select
  • checkbox [WIP]
  • radio
  • date
  • time
  • datetime
  • html5 inputs
    • pattern
    • number
    • range
  • typeahead
  • ui-select
  • complex form
  • themes

release

It would be great to get a new release of this component. I want to use the empty option on the test control, but it was added after the last release and I'm having issues building this myself as I'm new to angular apps

Examples?

Where have all the examples gone? There's no source for them in the master branch. Compiled and runnable examples are in the gh-pages branch, but there's no source there, either.

Trigger manually

Is there an option to trigger the edit manually from another button for example?
Thanks for your reply!

Angular 2.0

Hi, Thanks for the library. Can we use angular 2.0 to develop this lib?

Best,

Enhancement Request: Allow arbitrary event binding to "save" and "cancel" button methods

It would be great if the component API allowed access to the "save" and "cancel" button methods generically in such a way as we could bind arbitrary events to trigger them. For example:

<inline-editor 
  (keyup.enter)="onSubmit(value)"
  (keyup.esc)="cancel(value)"
  type="text" [(ngModel)]="editableText" (onSave)="saveEditable($event)" name="editableText1" 
  >
</inline-editor>

Empty option does not work with text area

I created a text entry:
<inline-editor type="text" empty="test" [(ngModel)]="slide.tweet" (onSave)="saveEditable($event)" name="tweetText" size="140"></inline-editor>

But the empty string is not shown when slide.tweet is an empty string ("") as opposed to null

commit #4877aed5f727ea2b14a85fc2e2e55eed0f865d28

ng2 final

Does your Code work with ng2 final? You write RC5 and later, but as the whole community is more than aware right now, final did break every conceivable dependency on RC5. Any plans to update your code to ng2-2.0.0, 2.1.0-rc1 or even 2.1.0 ?

Docs not updated with Angular 2.0 ?

<inline-editor type="text" [(ngModel)]="editableText">

this gives us

Error: Template parse errors:
Can't bind to 'ngModel' since it isn't a known property of 'inline-editor'.

  1. If 'inline-editor' is an Angular component and it has 'ngModel' input, then verify that it is part of this module.
  2. If 'inline-editor' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.

Div inside inlineEditorWrapper

Now there are a div inside inlineEditorWrapper which provoke a display:block in the design.

The ideal would be that it element was removed due to there are a div called inlineEditorWrapper which can be customize since CSS/SASS.

HTML in textarea?

HTML tags rendered inside of a text area when it's in the non-edit mode?

For instance, if my textarea is<p>Chunk of text.</p> it's rendering as <p>Chunk of text.</p> in both display mode and edit mode, instead of formatting based on the tags.

Unexpected value 'InlineEditorModule' imported by the module 'NewreconAppModule'

This issue closed but I am facing the same issue with angular 2
Could you guys help me to sort out this?

Anybody had this problem?

Unexpected value 'InlineEditorModule' imported by the module 'AppModule'.
in my app.module.ts:
`import { InlineEditorModule } from 'ng2-inline-editor';

...
@NgModule({
imports: [InlineEditorModule, ...],
declarations: [...]
`

in my template:
<inline-editor type="text" [(ngModel)]="editableText" (onSave)="saveEditable($event)" name="editableText1" size="8">

I installed using npm:

npm i ng2-inline-editor --save
Did I miss anything?

Possibility to clear field from code?

So, it seems that somehow the values get saved in the editable field, and this messes up the model if i'm for example changing the model from a component.

See GIF for example:
error

In the GIF, whenever i press the green button, the model gets nulled out to default values.

Is this an unfortunate bug or a direct fault on my side?
Is there any way of emptying the inputfield from code upon for example a save of the data?

typings: not found

This module keeps on failing on my build system with the following errors
10:08:24.279 npm ERR! Failed at the [email protected] postinstall script 'typings install'.

Demos in GitHub Pages

Hi,

I am practicing a little bit with Angular2 at the moment, saw your project today and it looks interesting. However, it would be nice to have the two demos (or if you add more in the future) in GitHub pages so it would be faster to try. The site would be http://caballerog.github.io/ng2-inline-editor, and it only requires a gh-pages branch in the current repo with the static files. Would you consider a pull request in the following days which would do the following?

  • Adds a githook postcommit which checks the git diff of the demos directory, and if it is not empty...
  • It changes to the gh-pages branch and generates a bundle for each demo, commits it, and changes back to the master branch again

I saw that you use webpack there so it should be straightforward. If you give the ok, my only comments would be that in my PR:

  • the script would be written in bash (it would not work in Windows)
  • the index page where it lists the demos would be really simple, just a list using basic bootstrap (you could improve it later)
  • the demos would have to work without a server. I see that one demo uses sockjs-node to retrieve the json, which I am not familiar with and I might have to change.

Please let me know what do you think, the main problem I see would be the third point (not being able to use a dynamic server for the demos)

Cheers

Support 'empty' for select inputs

I am trying to display a inline-editor of type select to edit entities with missing values. I need the dropdown to display even when the value of the bound ngModel does not exist within the options data collection. This seems to work well for type text where it displays the link of empty if it is empty. Similar functionality should be added to select. As of now you can't edit select field unless it has a matching option value.

alpha 20 break styling

In alpha 19, the styling had by default a red underlined text
screen shot 2017-05-19 at 10 58 27

With version alpha 20:
the text has no styling making it hard to see that user can click.

also the html generated seem to be missing some divs:
alpha 19:

<inline-editor _ngcontent-c3="" empty="Slide key takeaway" min="0" name="tweetText" size="140" type="text" _nghost-c2="" class="ng-untouched ng-pristine ng-valid"><div _ngcontent-c2=""> <div _ngcontent-c2="" id="inlineEditWrapper"> <a _ngcontent-c2="" class="editable-empty">Slide key takeaway</a> <div _ngcontent-c2="" class="inlineEditForm form-inline" hidden=""> <div _ngcontent-c2="" class="form-group"> <div _ngcontent-c2=""></div><inline-editor-text _nghost-c4="" ng-version="4.0.3"><input _ngcontent-c4="" class="form-control ng-untouched ng-pristine ng-valid" type="text" placeholder="" size="140"></inline-editor-text> <span _ngcontent-c2="" class="inline-editor-button-group"> <button _ngcontent-c2="" class="btn btn-xs btn-primary" id="inline-editor-button-save"><span _ngcontent-c2="" class="fa fa-check"></span></button> <button _ngcontent-c2="" class="btn btn-xs btn-danger"><span _ngcontent-c2="" class="fa fa-remove"></span> </button> </span> </div> </div> </div> </div></inline-editor>

(sorry for poor formatting could not figure what is wrong)

vs alpha 20:
<inline-editor _ngcontent-c2="" empty="Slide key takeaway" min="0" name="tweetText" size="140" type="text" class="ng-untouched ng-pristine ng-valid"><div> <div id="inlineEditWrapper"> <a class="editable-empty c-inline-editor">Slide key takeaway</a> <div class="c-inline-editor inlineEditForm form-inline" hidden=""> <div class="form-group"> <div></div><inline-editor-text _nghost-c3=""><input _ngcontent-c3="" class="form-control ng-untouched ng-pristine ng-valid" type="text" placeholder="" size="140"></inline-editor-text> <span class="c-inline-editor inline-editor-button-group"> <button class="btn btn-xs btn-primary c-inline-editor" id="inline-editor-button-save"><span class="fa fa-check"></span></button> <button class="btn btn-xs btn-danger c-inline-editor"><span class="fa fa-remove"></span> </button> </span> </div> </div> </div> </div></inline-editor>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.