@@ -16,11 +16,16 @@ export default {
1616 type : Boolean ,
1717 default : true ,
1818 } ,
19+ siblings : {
20+ type : Array ,
21+ default : ( ) => [ ] ,
22+ } ,
1923 } ,
2024
2125 data ( ) {
2226 return {
2327 editing : false ,
28+ editingId : null ,
2429 } ;
2530 } ,
2631
@@ -73,9 +78,10 @@ export default {
7378
7479 edit ( ) {
7580 if ( this . readOnly ) return ;
76- if ( this . asset . invalid ) return ;
81+ if ( this . asset ? .invalid ) return ;
7782
7883 this . editing = true ;
84+ this . editingId = this . asset ?. id ?? null ;
7985 } ,
8086
8187 remove ( ) {
@@ -98,6 +104,7 @@ export default {
98104
99105 closeEditor ( ) {
100106 this . editing = false ;
107+ this . editingId = null ;
101108 } ,
102109
103110 assetSaved ( asset ) {
@@ -108,10 +115,28 @@ export default {
108115 actionCompleted ( successful , response ) {
109116 if ( successful === false ) return ;
110117 const id = response . ids [ 0 ] || null ;
111- if ( id && id !== this . asset . id ) {
112- this . $emit ( 'id-changed' , id ) ;
118+ if ( id && id !== this . editingId ) {
119+ this . $emit ( 'id-changed' , this . editingId , id ) ;
113120 }
114121 this . closeEditor ( ) ;
115122 } ,
123+
124+ navigateToPrevious ( ) {
125+ const index = this . siblings . findIndex ( ( asset ) => asset . id === this . editingId ) ;
126+ if ( index <= 0 ) return ;
127+
128+ const previousId = this . siblings [ index - 1 ] . id ;
129+ this . editingId = null ;
130+ this . $nextTick ( ( ) => ( this . editingId = previousId ) ) ;
131+ } ,
132+
133+ navigateToNext ( ) {
134+ const index = this . siblings . findIndex ( ( asset ) => asset . id === this . editingId ) ;
135+ if ( index === - 1 || index >= this . siblings . length - 1 ) return ;
136+
137+ const nextId = this . siblings [ index + 1 ] . id ;
138+ this . editingId = null ;
139+ this . $nextTick ( ( ) => ( this . editingId = nextId ) ) ;
140+ } ,
116141 } ,
117142} ;
0 commit comments