@@ -502,8 +502,39 @@ jQuery(document).ready(function ($) {
502502 } ) ;
503503 } ) ;
504504
505+ /* field type: tags */
506+ let tags_field = null ;
507+ $ ( 'dt-tags' ) . on ( 'dt:add-new' , ( e ) => {
508+ tags_field = e . detail . field ;
509+ $ ( '#create-tag-modal' ) . foundation ( 'open' ) ;
510+ $ ( '.js-create-tag input[name=title]' ) . val ( e . detail . value ) ;
511+ } ) ;
512+
513+ $ ( '.js-create-tag' ) . on ( 'submit' , ( e ) => {
514+ e . preventDefault ( ) ;
515+
516+ const tag = $ ( '#new-tag' ) . val ( ) ;
517+ const field = document . querySelector ( `#${ tags_field } ` ) ;
518+ if ( field ) {
519+ // select the tag and the change event will handle saving it
520+ field . _select ( tag ) ;
521+ field . _clearSearch ( ) ;
522+ }
523+ } ) ;
524+
525+ // new record from group member list
526+ $ ( '.create-new-record' ) . on ( 'click' , function ( ) {
527+ connection_type = $ ( this ) . data ( 'connection-key' ) ;
528+ $ ( '#create-record-modal' ) . foundation ( 'open' ) ;
529+ $ ( '.js-create-record .error-text' ) . empty ( ) ;
530+ $ ( '.js-create-record-button' ) . attr ( 'disabled' , false ) . removeClass ( 'alert' ) ;
531+ $ ( '.reveal-after-record-create' ) . hide ( ) ;
532+ $ ( '.hide-after-record-create' ) . show ( ) ;
533+ $ ( '.js-create-record input[name=title]' ) . val ( '' ) ;
534+ } ) ;
535+
536+ /* field type: connection */
505537 let connection_type = null ;
506- // New record off of dt-connection
507538 $ ( 'dt-connection' ) . on ( 'change' , ( e ) => {
508539 if ( e ?. detail ?. newValue && e . detail . newValue . some ( ( x ) => x . isNew ) ) {
509540 e . stopImmediatePropagation ( ) ; // stop ComponentService listener from firing
@@ -522,7 +553,15 @@ jQuery(document).ready(function ($) {
522553 $ ( '.js-create-record input[name=title]' ) . val ( newPost . label ) ;
523554 }
524555 } ) ;
525-
556+ $ ( 'dt-connection' ) . on ( 'dt:add-new' , ( e ) => {
557+ connection_type = e . detail . field ;
558+ $ ( '#create-record-modal' ) . foundation ( 'open' ) ;
559+ $ ( '.js-create-record .error-text' ) . empty ( ) ;
560+ $ ( '.js-create-record-button' ) . attr ( 'disabled' , false ) . removeClass ( 'alert' ) ;
561+ $ ( '.reveal-after-record-create' ) . hide ( ) ;
562+ $ ( '.hide-after-record-create' ) . show ( ) ;
563+ $ ( '.js-create-record input[name=title]' ) . val ( e . detail . value ) ;
564+ } ) ;
526565 /* New Record Modal */
527566 $ ( '.js-create-record' ) . on ( 'submit' , function ( e ) {
528567 e . preventDefault ( ) ;
@@ -570,6 +609,7 @@ jQuery(document).ready(function ($) {
570609 [ newRecord ] ,
571610 ) [ 0 ] ,
572611 ) ;
612+ field . _clearSearch ( ) ;
573613 }
574614 } )
575615 . catch ( function ( error ) {
@@ -1316,6 +1356,7 @@ function record_updated(updateNeeded) {
13161356 * that make use of them. Leaving them here until we can be sure they can be
13171357 * completely removed.
13181358 */
1359+
13191360jQuery ( document ) . ready ( function ( $ ) {
13201361 let post_id = window . detailsSettings . post_id ;
13211362 let post_type = window . detailsSettings . post_type ;
0 commit comments