@@ -8,6 +8,9 @@ export default class UrlField {
88 this . $field = $el ;
99
1010 this . $linkExistsWarning = document . querySelector ( '.link-exists' ) ;
11+ this . $linkExistsEdit = this . $linkExistsWarning . querySelector ( '.link-exists-edit' ) ;
12+ this . $linkExistsRestore = this . $linkExistsWarning . querySelector ( '.link-exists-restore' ) ;
13+ this . $linkExistsRestoreId = document . querySelector ( '.link-exists-restore-id' ) ;
1114
1215 if ( ! this . $linkExistsWarning ) {
1316 return ;
@@ -52,12 +55,24 @@ export default class UrlField {
5255 } ) . then ( ( result ) => {
5356
5457 // If the link already exist, mark the field as invalid
55- if ( result . linkFound === true ) {
58+ if ( result . linkFound !== null ) {
59+
60+ if ( result . linkDeleted === true ) {
61+ this . $linkExistsEdit . classList . add ( 'd-none' ) ;
62+ this . $linkExistsRestore . classList . remove ( 'd-none' ) ;
63+ this . $linkExistsRestoreId . value = result . linkFound . id ;
64+ } else {
65+ this . $linkExistsRestore . classList . add ( 'd-none' ) ;
66+ this . $linkExistsLink . href = result . editLink ;
67+ this . $linkExistsEdit . classList . remove ( 'd-none' )
68+ }
5669 this . $field . classList . add ( 'is-invalid' ) ;
57- this . $linkExistsLink . href = result . editLink ;
5870 this . $linkExistsWarning . classList . remove ( 'd-none' ) ;
71+
5972 } else {
6073 this . $field . classList . remove ( 'is-invalid' ) ;
74+ this . $linkExistsEdit . classList . add ( 'd-none' ) ;
75+ this . $linkExistsRestore . classList . add ( 'd-none' ) ;
6176 this . $linkExistsWarning . classList . add ( 'd-none' ) ;
6277 this . $linkExistsLink . href = '' ;
6378 this . querySiteForMetaTags ( url ) ;
0 commit comments