Coder Social home page Coder Social logo

linkit-media-creation's People

Contributors

matt-mendonca-nist avatar zweishar avatar

Watchers

 avatar

linkit-media-creation's Issues

returnToLinkit command doesn't seem to update the linkit modal after creating a file

After uploading / creating a new media entity via the create pop up, the pop up closes but does not update the linkit insert modal with the value of the newly create media entity. Seems like an issue in somewhere: https://github.com/zweishar/Linkit-Media-Creation/blob/master/js/commands.js

As a quick and hacky way to get this working I did the following (understanding it's probably not the correct approach):

diff --git a/js/commands.js b/js/commands.js
index f21d53b..b9eaf43 100755
--- a/js/commands.js
+++ b/js/commands.js
@@ -12,26 +12,32 @@
     response,
     status
   ) {
-    var Formfields = {
-      "edit-attributes-href": response.returnValue,
-      "edit-attributes-data-entity-type": response.entityType,
-      "edit-attributes-data-entity-uuid": response.entityUUID,
-      "edit-attributes-data-entity-substitution": response.entitySubstitution,
-      "edit-href-dirty-check": response.returnValue
-    };
+    // var Formfields = {
+    //   "edit-attributes-href": response.returnValue,
+    //   "edit-attributes-data-entity-type": response.entityType,
+    //   "edit-attributes-data-entity-uuid": response.entityUUID,
+    //   "edit-attributes-data-entity-substitution": response.entitySubstitution,
+    //   "edit-href-dirty-check": response.returnValue
+    // };
 
-    var form = $("#" + response.inputId, opener.document);
+    // var form = $("#" + response.inputId, opener.document);
 
-    if (form.length > 0) {
-      for (var key in Formfields) {
-        if (Formfields.hasOwnProperty(key)) {
-          var el = $('[data-drupal-selector="' + key + '"]', form);
-          el.val(Formfields[key]).change();
-          if (key === "edit-attributes-href") {
-            el.focus();
-          }
-        }
-      }
+    // if (form.length > 0) {
+    //   for (var key in Formfields) {
+    //     if (Formfields.hasOwnProperty(key)) {
+    //       var el = $('[data-drupal-selector="' + key + '"]', form);
+    //       el.val(Formfields[key]).change();
+    //       if (key === "edit-attributes-href") {
+    //         el.focus();
+    //       }
+    //     }
+    //   }
+    // }
+
+    var linkitInputSelector = '.linkit-media-creation-url-input [data-drupal-selector="edit-attributes-href"]';
+
+    if ($(linkitInputSelector, opener.document).length > 0) {
+      $(linkitInputSelector, opener.document).val(response.returnValue).focus();
     }
 
     window.close();

Note: this is based off a vanilla 8.7.1 site with #1 and #2 applied.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.