-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
74 changed files
with
1,481 additions
and
294 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,68 @@ | ||
/* global $ */ | ||
$.extend({ | ||
observeSearchSelectControl () { | ||
$('.search_select_control').live({ | ||
click (e) { | ||
e.preventDefault(); | ||
|
||
var container = $(this).closest('ul'); | ||
|
||
$(this).closest('li.search_select').remove(); | ||
|
||
if (container.children('li').length === 0) { | ||
$('input#add_roles').prop('disabled', true); | ||
} | ||
} | ||
}); | ||
}, | ||
|
||
observeAutocomplete (url, rootId, paramName, containerId, elementClass, singleValue) { | ||
function split (val) { | ||
return val.split(/,\s*/); | ||
} | ||
|
||
function extractLast (term) { | ||
return split(term).pop(); | ||
} | ||
|
||
$(rootId) | ||
.live('keydown', function (event) { | ||
if (event.keyCode === $.ui.keyCode.TAB && $(this).data('autocomplete').menu.active) { | ||
event.preventDefault(); | ||
} | ||
}) | ||
.live('focus', function () { | ||
$(this) | ||
.autocomplete({ | ||
source (request, response) { | ||
$.getJSON(url, { | ||
term: extractLast(request.term) | ||
}, response); | ||
}, | ||
search () { | ||
const term = extractLast(this.value); | ||
if (term.length < 2) { | ||
return false; | ||
} | ||
}, | ||
focus () { | ||
return false; | ||
}, | ||
select (event, ui) { | ||
if (typeof singleValue != 'undefined' && singleValue === true) { | ||
$(containerId).empty(); | ||
} | ||
|
||
const node = $('<li>').attr('class', elementClass); | ||
$(node).html($('<input name="' + paramName + '[]" type="hidden" />').val(ui.item.value)) | ||
$(node).append(ui.item.label); | ||
$(node).append('<span class="search_select_control"> X </span>'); | ||
$(containerId).show().append(node); | ||
$('input#add_roles').prop('disabled', false); | ||
this.value = ''; | ||
return false; | ||
} | ||
}); | ||
}); | ||
} | ||
}); |
This file contains 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,32 @@ | ||
/* globals $ */ | ||
$('.hub_feed_more_control, .republished_feed_more_control') | ||
.live({ click: toggleListItemMetadata }) | ||
|
||
function toggleListItemMetadata (e) { | ||
e.preventDefault() | ||
|
||
var element = $(this) | ||
|
||
if (element.hasClass('more_details_included')) { | ||
hideListItemMetadata(element) | ||
} else { | ||
showListItemMetadata(element) | ||
} | ||
} | ||
|
||
function hideListItemMetadata (element) { | ||
element.removeClass('more_details_included') | ||
element.closest('li').find('.metadata').empty() | ||
element.find('.fa').removeClass('fa-caret-down').addClass('fa-caret-right') | ||
} | ||
|
||
function showListItemMetadata (element) { | ||
$.ajax({ | ||
url: element.attr('href'), | ||
success: function (html) { | ||
element.addClass('more_details_included') | ||
element.closest('li').find('.metadata').replaceWith(html) | ||
element.find('.fa').removeClass('fa-caret-right').addClass('fa-caret-down') | ||
} | ||
}) | ||
} |
This file contains 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 |
---|---|---|
@@ -1,61 +1 @@ | ||
/* global $ */ | ||
$.extend({ | ||
observeSearchSelectControl () { | ||
$('.search_select_control').live({ | ||
click (e) { | ||
e.preventDefault() | ||
|
||
var container = $(this).closest('ul') | ||
|
||
$(this).closest('li.search_select').remove() | ||
|
||
if (container.children('li').length === 0) { | ||
$('input#add_roles').prop('disabled', true) | ||
} | ||
} | ||
}) | ||
}, | ||
|
||
observeAutocomplete (url, rootId, paramName, containerId, elementClass) { | ||
function split (val) { | ||
return val.split(/,\s*/) | ||
} | ||
|
||
function extractLast (term) { | ||
return split(term).pop() | ||
} | ||
|
||
$(rootId) | ||
.bind('keydown', function (event) { | ||
if (event.keyCode === $.ui.keyCode.TAB && $(this).data('autocomplete').menu.active) { | ||
event.preventDefault() | ||
} | ||
}) | ||
.autocomplete({ | ||
source (request, response) { | ||
$.getJSON(url, { | ||
term: extractLast(request.term) | ||
}, response) | ||
}, | ||
search () { | ||
const term = extractLast(this.value) | ||
if (term.length < 2) { | ||
return false | ||
} | ||
}, | ||
focus () { | ||
return false | ||
}, | ||
select (event, ui) { | ||
const node = $('<li>').attr('class', elementClass) | ||
$(node).html($(`<input name="${paramName}[]" type="hidden" />`).val(ui.item.value)) | ||
$(node).append(ui.item.label) | ||
$(node).append('<span class="search_select_control"> X </span>') | ||
$(containerId).show().append(node) | ||
$('input#add_roles').prop('disabled', false) | ||
this.value = '' | ||
return false | ||
} | ||
}) | ||
} | ||
}) | ||
//= require autocomplete_user |
This file contains 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 @@ | ||
//= require autocomplete_user |
This file contains 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 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 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,31 @@ | ||
require 'tempfile' | ||
|
||
class ExportImportController < ApplicationController | ||
before_action :authenticate_user! | ||
|
||
def index | ||
breadcrumbs.add 'Export/import', export_import_path | ||
end | ||
|
||
def download | ||
data = Tagteam::ExportImport.get_all_user_data current_user | ||
|
||
send_data data, filename: format('tagteam_export_%s.json', Time.now) | ||
end | ||
|
||
def import | ||
if params[:file].nil? | ||
flash[:error] = 'File is missing, please try again.' | ||
else | ||
temp_file = Tempfile.new('tagteam_import') | ||
temp_file.write(File.read(params[:file].tempfile)) | ||
ObjectSpace.undefine_finalizer(temp_file) | ||
|
||
Sidekiq::Client.enqueue(ImportUserData, temp_file.path, current_user.email) | ||
|
||
flash[:notice] = 'Import is in progress. You will get an email notification when the import is done.' | ||
end | ||
|
||
redirect_to request.referer | ||
end | ||
end |
Oops, something went wrong.