File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1141,7 +1141,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
11411141 }
11421142 } ) ;
11431143
1144- this . __isNew = this . __isNew || ( this . items && this . items . indexOf ( item ) < 0 ) ;
1144+ this . __isNew = ! ! ( this . __isNew || ( this . items && this . items . indexOf ( item ) < 0 ) ) ;
11451145 this . editorOpened = true ;
11461146 }
11471147 }
Original file line number Diff line number Diff line change @@ -631,4 +631,30 @@ describe('crud buttons', () => {
631631 expect ( newButton . textContent ) . to . equal ( crud . i18n . cancel ) ;
632632 } ) ;
633633 } ) ;
634+
635+ describe ( 'dataProvider' , ( ) => {
636+ let items ;
637+
638+ beforeEach ( async ( ) => {
639+ crud = fixtureSync ( '<vaadin-crud style="width: 300px;"></vaadin-crud>' ) ;
640+ items = [ { foo : 'bar' } ] ;
641+ crud . dataProvider = ( _ , callback ) => callback ( items , items . length ) ;
642+ await nextRender ( crud . _grid ) ;
643+ saveButton = crud . querySelector ( '[slot=save-button]' ) ;
644+ deleteButton = crud . querySelector ( '[slot=delete-button]' ) ;
645+ } ) ;
646+
647+ it ( 'should hide delete button on new' , async ( ) => {
648+ crud . $ . new . click ( ) ;
649+ await nextRender ( crud . $ . dialog . $ . overlay ) ;
650+ expect ( deleteButton . hasAttribute ( 'hidden' ) ) . to . be . true ;
651+ } ) ;
652+
653+ it ( 'should show delete button and disable save button on edit' , async ( ) => {
654+ edit ( items [ 0 ] ) ;
655+ await nextRender ( crud . $ . dialog . $ . overlay ) ;
656+ expect ( saveButton . hasAttribute ( 'disabled' ) ) . to . be . true ;
657+ expect ( deleteButton . hasAttribute ( 'hidden' ) ) . not . to . be . true ;
658+ } ) ;
659+ } ) ;
634660} ) ;
You can’t perform that action at this time.
0 commit comments