...
 
Commits (3)
......@@ -72,7 +72,7 @@ class ActivityGalleryPlugin::Activity
"scope_ids" => scopes || [],
"audience_ids" => audiences|| [],
"space_type_ids" => space_types|| [],
"license_id" => license.to_h[":id"],
"license_id" => license,
"person_ids" => authors.try(:split, ','),
"external_authors" => external_authors.try(:split, ','),
"specific_materials" => specific_materials || [],
......@@ -100,7 +100,7 @@ class ActivityGalleryPlugin::Activity
@license = JSON.parse(result.body,symbolize_names:true)
result = []
@license[:data].each do |license|
field = [license[:attributes][:title], license[:id]]
field = [license[:attributes][:title], license[:id], license[:attributes][:'allow-commercial-use'], license[:attributes][:'allow-modify']]
result.push(field)
end
result
......
class ActivityGalleryPlugin::Request
class << self
def request(method, url, body, jwt)
base_url = "https://api.aprendizagemcriativa.org/"
base_url = "https://stagingapi.aprendizagemcriativa.org/"
uri = URI.parse(base_url + url)
request = "Net::HTTP::#{method.to_s.camelize}".constantize.new(uri)
request.content_type = "application/json"
......
......@@ -12,7 +12,7 @@
<div class="form-content">
<div class="activity-subtitle">Sobre a Atividade</div>
<%= labelled_form_field(_('Título * Campo Obrigatório'), text_area_tag('data[title]', @activity.title, placeholder: 'Título da Atividade')) %>
<%= labelled_form_field(_('Título*'), text_area_tag('data[title]', @activity.title, placeholder: 'Título da Atividade')) %>
<%= labelled_form_field(_('Subtítulo'), text_area_tag('data[caption]', @activity.caption, placeholder: 'Linha de apoio complementar ao título principal')) %>
<%= file_field_or_thumbnail(_('Foto ou imagem ilustrativa para a atividade:'), @activity.original_image, 'data[image_builder]') %>
<%= labelled_form_field(_('Quem criou esta atividade?')+' ', token_input_field_tag('data[authors]', 'search-authors', {:controller => 'activity_gallery_plugin_activity', :action => 'search_authors'}, {:focus => false, :hint_text => _('Digite o nome do autor'), :pre_populate => @activity.tokenized_authors})
......@@ -38,9 +38,28 @@
<%= labelled_form_field(_('Pré-requisitos'), text_area_tag('data[requirements]', @activity.requirements, placeholder: 'A atividade exige pré-requisito dos participantes? Descreva.')) %>
<%= labelled_form_field(_('Copyright'), text_area_tag('data[copyright]', @activity.copyright, placeholder: 'Quem deve ser listado no Copyright?')) %>
<div class="select-license-type">
<%= labelled_form_field(_('Tipo de licença')+' ', select_tag('data[license][:id]', options_for_select(ActivityGalleryPlugin::Activity.get_license_options(jwt), @activity.license[:id])) ) %>
<%= modal_link_to _('Informações sobre as licenças Creative Commons | Modal'), { controller: 'activity_gallery_plugin_activity', action: 'license_types' } %>
<div class="formfieldline select-license-type">
<% licenses = ActivityGalleryPlugin::Activity.get_license_options(jwt) %>
<label class="formlabel">Tipos de Licença</label>
<p>Permitir uso comercial</p>
<%= labelled_radio_button('Sim', 'commercial', 'commercial', true, class: 'radios_licenses') %>
<%= labelled_radio_button('Não', 'commercial', 'non-commercial', false, class: 'radios_licenses') %>
<p>Permitir modificações</p>
<%= labelled_radio_button('Sim', 'modify', 'modify', true, class: 'radios_licenses') %>
<%= labelled_radio_button('Não', 'modify', 'non-modify', false, class: 'radios_licenses') %>
<%= labelled_radio_button('Sim, compartilhar igual', 'modify', 'modify+share-alike', false, class: 'radios_licenses') %>
<%= hidden_field_tag('data[license]', licenses.select{ |l| l[2] == 'commercial' && l[3] == 'modify'}[0][1], id: 'license_input') %>
<input
id='license_show'
class="button with-text submit btn-save-activity"
type='button'
disabled="disabled"
value="<%= licenses.select{|l| l[2] == @activity.license[:allow_commercial_use] || 'commercial' && l[3] == @activity.license[:allow_modify] || 'modify'}[0][0] %>"
>
<%= modal_link_to _('Informações sobre as licenças Creative Commons | Modal'), { controller: 'activity_gallery_plugin_activity', action: 'license_types' } %>
</div>
</div>
<% end %>
<% if activity_type == 'internal' %>
<%= labelled_form_field(_('Motivação'), text_area_tag('data[motivation]', @activity.motivation, maxlength: 500, placeholder: 'Conte um pouco sobre o contexto em que esta atividade foi elaborada.')) %>
......@@ -60,11 +79,28 @@
<%= labelled_form_field(_('Histórico'), text_area_tag('data[version_history]', @activity.version_history, placeholder: 'Histórico das versões')) %>
<%= labelled_form_field(_('Copyright'), text_area_tag('data[copyright]', @activity.copyright, placeholder: 'Quem deve ser listado no Copyright?')) %>
<div class="select-license-type">
<%= labelled_form_field(_('Tipo de licença')+' ', select_tag('data[license][:id]', options_for_select(ActivityGalleryPlugin::Activity.get_license_options(jwt), @activity.license[:id])) ) %>
<%= modal_link_to _('Informações sobre as licenças Creative Commons | Modal'), { controller: 'activity_gallery_plugin_activity', action: 'license_types' } %>
<div class="formfieldline select-license-type">
<% licenses = ActivityGalleryPlugin::Activity.get_license_options(jwt) %>
<label class="formlabel">Tipos de Licença</label>
<p>Permitir uso comercial</p>
<%= labelled_radio_button('Sim', 'commercial', 'commercial',true || @activity.license[:allow_commercial_use] == 'commercial', class: 'radios_licenses') %>
<%= labelled_radio_button('Não', 'commercial', 'non-commercial', @activity.license[:allow_commercial_use] == 'non-commercial', class: 'radios_licenses') %>
<p>Permitir modificações</p>
<%= labelled_radio_button('Sim', 'modify', 'modify', true || @activity.license[:allow_modify] == 'modify', class: 'radios_licenses') %>
<%= labelled_radio_button('Não', 'modify', 'non-modify', @activity.license[:allow_modify] == 'non-modify', class: 'radios_licenses') %>
<%= labelled_radio_button('Sim, compartilhar igual', 'modify', 'modify+share-alike', @activity.license[:allow_modify] == 'modify+share-alike', class: 'radios_licenses') %>
<%= hidden_field_tag('data[license]', licenses.select{ |l| l[2] == 'commercial' && l[3] == 'modify'}[0][1], id: 'license_input') %>
<input
id='license_show'
class="button with-text submit btn-save-activity"
type='button'
disabled="disabled"
value="<%= licenses.select{|l| l[2] == @activity.license[:allow_commercial_use] || 'commercial' && l[3] == @activity.license[:allow_modify] || 'modify'}[0][0] %>"
>
<%= modal_link_to _('Informações sobre as licenças Creative Commons | Modal'), { controller: 'activity_gallery_plugin_activity', action: 'license_types' } %>
</div>
</div>
<div class="activity-subtitle">Preparação da Atividade</div>
<%= labelled_form_field(_('Tipo de Espaço: Indique o tipo de espaço onde a atividade foi ou pode ser implementada.')+' ',
ActivityGalleryPlugin::Activity.get_space_types_options(jwt).map do |space|
......@@ -113,6 +149,17 @@
<%= render partial: 'shared/text_editor_summernote' %>
<script>
jQuery('#external-authors').inputosaurus({
})
jQuery('#external-authors').inputosaurus({ })
const license_input = document.getElementById('license_input')
const license_show = document.getElementById('license_show')
const radios_licenses = document.getElementsByClassName('radios_licenses')
const data = JSON.parse("<%= ActivityGalleryPlugin::Activity.get_license_options(jwt) %>".replace(/&quot;/g, '\"'))
const setLicense = () => {
let allow_commercial_use = Array.from(document.querySelectorAll('[name="commercial"]')).filter(c => c.checked)
let allow_modify = Array.from(document.querySelectorAll('[name="modify"]')).filter(m => m.checked)
license_input.value = data.filter(d => d[2] == allow_commercial_use[0].value && d[3] == allow_modify[0].value)[0][1]
license_show.value = data.filter(d => d[2] == allow_commercial_use[0].value && d[3] == allow_modify[0].value)[0][0]
}
for(let i = 0; i < radios_licenses.length; i++) radios_licenses[i].addEventListener('change', setLicense)
</script>