Coder Social home page Coder Social logo

astr's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

astr's Issues

Being able to remove file before upload

If I dragged and dropped a file I finally do not want to upload, I want to be able to remove it without refreshing the whole page and losing the values I already typed in the fields.

Loading a saved search does not always return correct results

In public/js/explore.js in the following code:

  // ---------------------------- Page Loading ----------------------------- //

  // use the saved search if present in URL
  if (getUrlParameter('search')) {
    $.get('api/search/id/' + getUrlParameter('search'), function(search) {
      if (search._id) {
        return new Promise(function(resolve) {
          if (search.date) {
            if (typeof search.date === 'string') {
              // unique date
              $('#inputDate').val(search.date);
            } else {
              // date range
              $('#checkboxDateRange').trigger('click');
              $('#inputDate2').prop('disabled', false);
              $('#inputDate').val(search.date[0]);
              $('#inputDate2').val(search.date[1]);
            }
          }
          if (search.archiveCategory) {
            $('#selectCategory').val(search.archiveCategory);
            $('#selectCategory').trigger('change');
          }
          if (search.archiveAuthor) {
            $('#selectAuthor').val(search.archiveAuthor);
          }
          if (search.descriptors.length > 0) {
            search.descriptors.forEach(function(descriptor) {
              selectedDescriptor.push(descriptor.name);
              addDescriptorToForm(descriptor.name, descriptor.value, descriptor.regex)
              });
          }
          if (search.ids.length > 0) {
            $('#inputIds').val(search.ids.join(', '));
          }
          setTimeout(function() {
            resolve();
          }, 100);
        }).then(function() {
          $('#form-search').trigger('change');
        });
      } else {
        console.log('Error with the search ID in params.');
        console.log(search);
      }
    });

There are two triggers leading to a search and a refresh of the results:

$('#selectCategory').trigger('change');
...
$('#form-search').trigger('change');

The issue is that they happen too fast one after the other, and they are both asynchronous.

  • If the first search is over before the second one, it is alright the list of result is corresponding to the full search form with all the descriptors, because it is the last trigger which leads to the displayed results.
  • If the first search lasts longer than the second one, the second search is being masked by the first one, and the displayed results are not correct. This happens when the second search leads to a few number of results while the first search leads to a great number of results. Indeed, the first search is triggered when only the category is set, and the second search is triggered when all the descriptors are set.

What needs to be done (two possibilities):

  • Avoid triggering a search while updating the category, it is unnecessary because this search is immediately erased by the second one (the real one).
  • Wait for the end of the first search before triggering the second one. But it may lead to unnecessary lag.

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.