@@ -64,6 +64,10 @@ type ItemValue = {
6464 * Enabled flag
6565 */
6666 e : boolean
67+ /**
68+ * Locked flag
69+ */
70+ l : boolean
6771 /**
6872 * Allow to delay
6973 */
@@ -94,7 +98,7 @@ type ItemValue = {
9498}
9599
96100const cvtItem2Rec = ( item : ItemValue ) : LimitRecord => {
97- const { i, n, c, t, v, p, e, ad, wd, wt, r, ct, wct, } = item
101+ const { i, n, c, t, v, p, e, l , ad, wd, wt, r, ct, wct, } = item
98102 const records : DateRecords = { }
99103 Object . entries ( r || { } ) . forEach ?.( ( [ date , { m, d, c } ] ) => records [ date ] = { mill : m , delay : d , visit : c } )
100104 return {
@@ -111,6 +115,7 @@ const cvtItem2Rec = (item: ItemValue): LimitRecord => {
111115 allowDelay : ! ! ad ,
112116 weekdays : wd ,
113117 records : records ,
118+ locked : l ,
114119 }
115120}
116121
@@ -121,9 +126,9 @@ function migrate(exist: Items, toMigrate: any) {
121126 Object . values ( toMigrate ) . forEach ( ( value , idx ) => {
122127 const id = idBase + idx
123128 const itemValue : ItemValue = value as ItemValue
124- const { c, n, t, e, ad, v, p } = itemValue
129+ const { c, n, t, e, l , ad, v, p } = itemValue
125130 exist [ id ] = {
126- i : id , c, n, t, e : ! ! e , ad : ! ! ad , v, p,
131+ i : id , c, n, t, e : ! ! e , l : ! ! l , ad : ! ! ad , v, p,
127132 r : { } ,
128133 }
129134 } )
@@ -162,7 +167,7 @@ class LimitDatabase extends BaseDatabase {
162167 const items = await this . getItems ( )
163168 let {
164169 id, name, weekdays,
165- enabled, allowDelay,
170+ enabled, locked , allowDelay,
166171 cond,
167172 time, count,
168173 weekly, weeklyCount,
@@ -181,7 +186,7 @@ class LimitDatabase extends BaseDatabase {
181186 // Can be overridden by existing
182187 ...( existItem || { } ) ,
183188 i : id , n : name , c : cond , wd : weekdays ,
184- e : ! ! enabled , ad : ! ! allowDelay ,
189+ e : ! ! enabled , l : locked , ad : ! ! allowDelay ,
185190 t : time , ct : count ,
186191 wt : weekly , wct : weeklyCount ,
187192 v : visitTime , p : periods ,
@@ -247,6 +252,13 @@ class LimitDatabase extends BaseDatabase {
247252 await this . update ( items )
248253 }
249254
255+ async updateLocked ( id : number , locked : boolean ) {
256+ const items = await this . getItems ( )
257+ if ( ! items [ id ] ) return
258+ items [ id ] . l = ! ! locked
259+ await this . update ( items )
260+ }
261+
250262 async importData ( data : any ) : Promise < void > {
251263 let toImport = data [ KEY ] as Items
252264 // Not import
0 commit comments