@@ -77,15 +77,55 @@ Ext.define('Admin.Database.Spaces', {
77
77
}
78
78
} ,
79
79
80
- truncateSpace ( space ) {
80
+ keyEmptyCheck ( key ) {
81
+ return ! key || key . every ( v => v == null ) ;
82
+ } ,
83
+
84
+ keyValidCheck ( key ) {
85
+ var isValid = true ;
86
+
87
+ if ( this . keyEmptyCheck ( key ) ) {
88
+ isValid = false ;
89
+ }
90
+ else {
91
+ for ( let i = 0 ; i < key . length - 1 ; i ++ ) {
92
+ if ( key [ i ] == undefined && key [ i + 1 ] != undefined ) {
93
+ isValid = false ;
94
+ break ;
95
+ }
96
+ }
97
+ }
98
+
99
+ return isValid ;
100
+ } ,
101
+
102
+ truncateSpace ( space , searchdata = undefined ) {
103
+ var params = this . spaceParams ( space ) ;
104
+
105
+ var message =
106
+ 'Are you sure to truncate space ' + space + '?<br/>' +
107
+ 'This operation can not be undone' ;
108
+
109
+ if ( searchdata && searchdata . index >= 0 ) {
110
+ if ( ! this . keyValidCheck ( searchdata . key ) ) {
111
+ Ext . Msg . alert ( 'Warning!' , 'Not valid key. Please, fill in all fields starting from the first.' ) ;
112
+ return ;
113
+ }
114
+
115
+ Ext . apply ( params , searchdata ) ;
116
+ message = 'Are you sure to delete tuples by index ' + searchdata . indexObj . name +
117
+ ' and key ' + searchdata . key + ' from space ' + space + '?<br/>' +
118
+ 'This operation can not be undone' ;
119
+ }
120
+
81
121
Ext . MessageBox . confirm ( {
82
122
title : 'Danger!' ,
83
123
icon : Ext . MessageBox . WARNING ,
84
- message : 'Are you sure to truncate space ' + space + '?<br/>This operation can not be undone' ,
124
+ message : message ,
85
125
buttons : Ext . MessageBox . YESNO ,
86
126
callback : ( answer ) => {
87
127
if ( answer == 'yes' ) {
88
- dispatch ( 'space.truncate' , this . spaceParams ( space ) )
128
+ dispatch ( 'space.truncate' , params )
89
129
. then ( ( ) => {
90
130
this . refreshSpaces ( ) ;
91
131
this . up ( 'database-tab' ) . items . each ( item => {
0 commit comments