- 
                Notifications
    You must be signed in to change notification settings 
- Fork 79
Share studies in studies #1755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
            antgonza
  merged 8 commits into
  qiita-spots:master
from
squirrelo:share-studies-in-studies
  
      
      
   
  Apr 9, 2016 
      
    
  
     Merged
                    Share studies in studies #1755
Changes from all commits
      Commits
    
    
            Show all changes
          
          
            8 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      f34d3c1
              
                make tornado changes needed for server side autocomplete
              
              
                squirrelo 2faeb47
              
                upate UI to use selected2 and ajax autocomplete
              
              
                squirrelo ad677e1
              
                break sharing JS into own file
              
              
                squirrelo 7846413
              
                add sharing to study page Fix #1730 Fix #1092
              
              
                squirrelo f22a50c
              
                add user to autocomplete list when verified
              
              
                squirrelo 38d1bb2
              
                test updates
              
              
                squirrelo e369520
              
                address comments
              
              
                squirrelo c177213
              
                jquery and javascript notation cleanup
              
              
                squirrelo File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| var current_study = null; | ||
|  | ||
| $(document).ready(function () { | ||
| $('#shares-select').select2({ | ||
| ajax: { | ||
| url: "/study/sharing/autocomplete/", | ||
| dataType: 'json', | ||
| delay: 250, | ||
| data: function (params) { | ||
| return {text: params.term}; | ||
| }, | ||
| cache: true | ||
| }, | ||
| minimumInputLength: 1, | ||
| formatResult: function (data, term) { | ||
| return data; | ||
| } | ||
| }); | ||
|  | ||
| $('#shares-select').on("select2:select", function (e) { | ||
| update_share({selected: e.params.data.text}); | ||
| }); | ||
|  | ||
| $('#shares-select').on("select2:unselect", function (e) { | ||
| update_share({deselected: e.params.data.text}); | ||
| }); | ||
| }); | ||
|  | ||
| function modify_sharing(study_id) { | ||
| var shared_list; | ||
| current_study = study_id; | ||
| $.get('/study/sharing/', {study_id: study_id}) | ||
| .done(function(data) { | ||
| var users_links = JSON.parse(data); | ||
| var users = users_links.users; | ||
| //empty dropdown and repopulate with new study shared values | ||
| $('#shares-select').html(''); | ||
| for(var i=0;i<users.length;i++) { | ||
| var shared = new Option(users[i], users[i], true, true); | ||
| $("#shares-select").append(shared).trigger('change'); | ||
| } | ||
| $("#shares-select").trigger("change"); | ||
| }); | ||
| } | ||
|  | ||
| function update_share(params) { | ||
| data = params || {}; | ||
| data.study_id = current_study; | ||
| $.get('/study/sharing/', data) | ||
| .done(function(data) { | ||
| users_links = JSON.parse(data); | ||
| links = users_links.links; | ||
| $("#shared_html_"+current_study).html(links); | ||
| }); | ||
| } | ||
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way to not use this global variable? Global variables in JavaScript are a slippery slope, and it tends to be really hard to recover from its (ab)use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, seems like
usersandusers_linksare all global 😭There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was a forgotten var. Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From offline conversation, @ElDeveloper and I agree it's not feasible to remove this global variable at this time.