GithubHelp home page GithubHelp logo

Comments (7)

jirikuncar avatar jirikuncar commented on August 21, 2024

@JakeCowton Do you have somewhere the tmp fix we have done together on your machine?

from invenio.

JakeCowton avatar JakeCowton commented on August 21, 2024

Yes.

  /**
   * Update the value of a field to a new one.
   */
  function handle_field_values(name, value) {
      if (name == 'files'){
          $.each(value, function(i, file){
              id = unique_id();

              new_file = {
                  id: id,
                  name: file.name,
                  size: file.size
              };

              $('#filelist').append(tpl_file_entry.render({
                  id: id,
                  filename: file.name,
                  filesize: getBytesWithUnit(file.size)
              }));
              $('#filelist #' + id).show('fast');
          });
          $('#file-table').show('fast');
      } else {
          clear_error(name);
          has_ckeditor = $('[name=' + name + ']').data('ckeditor');
          if( has_ckeditor === 1) {
              if(CKEDITOR.instances[name].getData(value) != value) {
                  CKEDITOR.instances[name].setData(value);
              }
          } else if (field_lists !== undefined && name in field_lists &&
                     value instanceof Array) {

            var $field = $('#'+name)
            if ($field.hasClass('dynamic-field-list')) {
              // TODO check that number of dynamic fields in the list is greather or equal to value.length
              // #<name> a.add-element .click()
              if ($field.children('.field-list-element').length < value.length) {
                $field.children('.add-element').click();
              }
            }

              for(var i = 0; i < value.length; i++){
                  field_lists[name].update_element(value[i], i);
              }
          } else {
              if($('[name=' + name + ']').val() != value) {
                  $('[name=' + name + ']').val(value);
              }
          }
      }

from invenio.

jirikuncar avatar jirikuncar commented on August 21, 2024

@JakeCowton A patch would be better.

from invenio.

JakeCowton avatar JakeCowton commented on August 21, 2024
From 5988a55a3fb8842853393a07a4ea290f6f36bc44 Mon Sep 17 00:00:00 2001
From: Jake Cowton <[email protected]>
Date: Tue, 25 Mar 2014 17:46:13 +0100
Subject: [PATCH 2/2] Data Analysis: Initial Commit

---
 invenio/modules/deposit/static/js/deposit/form.js | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/invenio/modules/deposit/static/js/deposit/form.js b/invenio/modules/deposit/static/js/deposit/form.js
index dd07282..77618e5 100644
--- a/invenio/modules/deposit/static/js/deposit/form.js
+++ b/invenio/modules/deposit/static/js/deposit/form.js
@@ -282,6 +282,16 @@ var DEPOSIT_FORM = (function( $ ){
               }
           } else if (field_lists !== undefined && name in field_lists &&
                      value instanceof Array) {
+
+            var $field = $('#'+name)
+            if ($field.hasClass('dynamic-field-list')) {
+              // TODO check that number of dynamic fields in the list is greather or equal to value.length
+              // #<name> a.add-element .click()
+              if ($field.children('.field-list-element').length < value.length) {
+                $field.children('.add-element').click();
+              }
+            }
+
               for(var i = 0; i < value.length; i++){
                   field_lists[name].update_element(value[i], i);
               }
-- 
1.9.1

from invenio.

JakeCowton avatar JakeCowton commented on August 21, 2024

@jirikuncar do you have any ideas what the problem here could be?

from invenio.

jirikuncar avatar jirikuncar commented on August 21, 2024

// TODO check that number of dynamic fields in the list is greather or equal to value.length

Have you implemented the TODO?

from invenio.

JakeCowton avatar JakeCowton commented on August 21, 2024

Yes. It's the two lines below.

from invenio.

Related Issues (20)

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.