Commit cf3210f0f9a4174819c415a9e2309506a79d125e
1 parent
e1d1cc3c
Exists in
master
and in
5 other branches
Ajustes em editar topico #400
Showing
5 changed files
with
49 additions
and
24 deletions
Show diff stats
courses/static/js/topic.js
1 | 1 | var topic = { |
2 | - get: function (button, url, id_div, faz){ | |
3 | - if(!$(id_div + ' div').length || faz == 'true'){ | |
2 | + get: function (url, id_div, faz,button){ | |
3 | + if((!$(id_div + ' div').length) || (faz == 'true')){ | |
4 | 4 | var opened = $("#topics").find(".fa-angle-up"); |
5 | - | |
5 | + | |
6 | 6 | if (opened.length > 0) { |
7 | 7 | opened.removeClass("fa-angle-up"); |
8 | 8 | opened.addClass("fa-angle-down"); |
... | ... | @@ -16,20 +16,21 @@ var topic = { |
16 | 16 | op_topic.find(".loaded").val("false"); |
17 | 17 | } |
18 | 18 | |
19 | - //Changing button icon | |
20 | - button.find("i").removeClass('fa-angle-down'); | |
21 | - button.find("i").addClass('fa-angle-up'); | |
22 | - | |
23 | 19 | $.get(url, function(data){ |
24 | 20 | $(id_div).empty(); |
25 | 21 | $(id_div).append(data); |
26 | 22 | }); |
23 | + if (faz == 'false'){ | |
24 | + //Changing button icon | |
25 | + button.find("i").removeClass('fa-angle-down'); | |
26 | + button.find("i").addClass('fa-angle-up'); | |
27 | + } | |
27 | 28 | } else { |
28 | 29 | var loaded = $(id_div).find(".loaded").val(); |
29 | 30 | |
30 | 31 | if (loaded == "true") { |
31 | 32 | var opened = $("#topics").find(".fa-angle-up"); |
32 | - | |
33 | + | |
33 | 34 | opened.removeClass("fa-angle-up"); |
34 | 35 | opened.addClass("fa-angle-down"); |
35 | 36 | var op_topic = opened.parent().parent().parent().parent().parent(); |
... | ... | @@ -42,7 +43,7 @@ var topic = { |
42 | 43 | $(id_div).find(".loaded").val("false"); |
43 | 44 | } else { |
44 | 45 | var opened = $("#topics").find(".fa-angle-up"); |
45 | - | |
46 | + | |
46 | 47 | opened.removeClass("fa-angle-up"); |
47 | 48 | opened.addClass("fa-angle-down"); |
48 | 49 | var op_topic = opened.parent().parent().parent().parent().parent(); |
... | ... | @@ -57,7 +58,7 @@ var topic = { |
57 | 58 | var opened = $(id_div).parent().parent().find(".fa-angle-down"); |
58 | 59 | opened.removeClass("fa-angle-down"); |
59 | 60 | opened.addClass("fa-angle-up"); |
60 | - | |
61 | + | |
61 | 62 | var log_url = $(id_div).find(".log_url").val(); |
62 | 63 | |
63 | 64 | topicLog(log_url, 0, 'open', id_div); |
... | ... | @@ -93,6 +94,23 @@ var delete_topic = { |
93 | 94 | } |
94 | 95 | }; |
95 | 96 | |
97 | +var RemoveTopic = { | |
98 | + remove: function(url,dados,id_li_link){ | |
99 | + $("#topic").modal('toggle'); | |
100 | + $.post(url,dados, function(data){ | |
101 | + $(id_li_link).remove(); | |
102 | + $('body').removeClass('modal-open'); | |
103 | + $("#modal_subject").empty(); | |
104 | + $(".modal-backdrop.in").remove(); | |
105 | + alertify.success("Topic removed successfully!"); | |
106 | + }).fail(function(){ | |
107 | + $("#modal_subject").empty(); | |
108 | + $("#modal_subject").append(data); | |
109 | + $('#topic').modal('show'); | |
110 | + }); | |
111 | + } | |
112 | +} | |
113 | + | |
96 | 114 | function topicLog(url, topic_log_id, action, topic_div) { |
97 | 115 | $.ajax({ |
98 | 116 | url: url, |
... | ... | @@ -109,4 +127,4 @@ function topicLog(url, topic_log_id, action, topic_div) { |
109 | 127 | console.log(data); |
110 | 128 | } |
111 | 129 | }) |
112 | -} | |
113 | 130 | \ No newline at end of file |
131 | +} | ... | ... |
courses/templates/topic/delete.html
1 | 1 | {% load static i18n permission_tags %} |
2 | 2 | |
3 | 3 | <!-- Modal (remember to change the ids!!!) --> |
4 | -<div class="modal fade" id="topic_delete_{{topic.slug}}" tabindex="-1" role="dialog" aria-labelledby="{{topic.slug}}_delete"> | |
4 | +<div class="modal fade" id="topic" tabindex="-1" role="dialog" aria-labelledby="{{topic.slug}}_delete"> | |
5 | 5 | <div class="modal-dialog" role="document"> |
6 | 6 | <div class="modal-content"> |
7 | 7 | <!-- Modal Header --> |
... | ... | @@ -22,6 +22,13 @@ |
22 | 22 | <!-- Don't remove that!!! --> |
23 | 23 | <button type="button" class="btn btn-default btn-raised" data-dismiss="modal">{% trans "Close" %}</button> |
24 | 24 | <button type="submit" id="button" form="topic_form" class="btn btn-primary btn-raised">{% trans "Delete" %}</button> |
25 | + | |
26 | + <script> | |
27 | + $("#topic_form").submit(function(event) { | |
28 | + RemoveTopic.remove("{% url 'course:delete_topic' topic.slug %}",$(this).serialize(),"#topic_all_{{topic.slug}}"); | |
29 | + event.preventDefault(); | |
30 | + }); | |
31 | + </script> | |
25 | 32 | </div> |
26 | 33 | </div> |
27 | 34 | </div> | ... | ... |
courses/templates/topic/index.html
1 | 1 | {% load i18n professor_access %} |
2 | 2 | |
3 | -<div class="panel panel-default cards-detail"> | |
3 | +<div class="panel panel-default cards-detail" id="topic_all_{{topic.slug}}"> | |
4 | 4 | <div class="panel-heading topic"> |
5 | 5 | <div class="row"> |
6 | 6 | <div class="col-md-1 moreAccordion" data-toggle="collapse" data-parent="#topics" href=".collapseTopic-{{topic.slug}}" aria-expanded="false" aria-controls="collapseTopic-{{topic.slug}}"> |
7 | - <button class="btn btn-default btn-sm caret-square" onclick="topic.get($(this), '{% url 'course:view_topic' topic.slug %}', '#content_topic_{{topic.slug}}', 'false');"><i class="fa fa-angle-down fa-2x" aria-hidden="true"></i></button> | |
7 | + <button class="btn btn-default btn-sm caret-square" onclick="javascript:topic.get('{% url 'course:view_topic' topic.slug %}', '#content_topic_{{topic.slug}}', 'false',$(this));"><i class="fa fa-angle-down fa-2x" aria-hidden="true"></i></button> | |
8 | 8 | </div> |
9 | 9 | <div class="col-xs-9 col-md-9 titleTopic Topic-detail"> |
10 | 10 | <a role="button"> |
... | ... | @@ -13,20 +13,20 @@ |
13 | 13 | </div><!--column --> |
14 | 14 | {# dropdown de topic com as opções de replicar, editar e deletar #} |
15 | 15 | {% professor_subject topic.subject user as dropdown_topic %} |
16 | - {% if dropdown_topic %} | |
16 | + {% if dropdown_topic %} | |
17 | 17 | <div class="col-xs-3 col-md-2 divMoreActions"> |
18 | 18 | <div class="btn-group"> |
19 | 19 | <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> |
20 | 20 | <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> |
21 | 21 | </button> |
22 | 22 | |
23 | - | |
23 | + | |
24 | 24 | <ul class="dropdown-menu pull-right" aria-labelledby="moreActions"> |
25 | 25 | <li><a href="{% url 'course:replicate_topic' topic.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i> {% trans "Replicate" %}</a></li> |
26 | 26 | <li><a href="javascript:topic.get('{% url 'course:update_topic' topic.slug %}','#content_topic_{{topic.slug}}','true');"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i> {% trans "Edit" %}</a></li> |
27 | - <li><a href="javascript:delete_topic.get('{% url 'course:delete_topic' topic.slug %}?view=index','#topic_delete_{{topic.slug}}','#modal_topic');"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans "Remove" %}</a></li> | |
27 | + <li><a href="javascript:delete_topic.get('{% url 'course:delete_topic' topic.slug %}','#topic','#modal_subject');"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans "Remove" %}</a></li> | |
28 | 28 | </ul> |
29 | - | |
29 | + | |
30 | 30 | </div> |
31 | 31 | </div> |
32 | 32 | {% endif %} |
... | ... | @@ -34,7 +34,7 @@ |
34 | 34 | </div> |
35 | 35 | <div class="panel-collapse collapseTopic-{{topic.slug}} topic_{{ topic.id }} collapse" role="tabpanel" aria-labelledby="heading_{{topic.id}}" aria-expanded="false" aria-hidden="true"> |
36 | 36 | <div class="panel-body" id="content_topic_{{topic.slug}}"> |
37 | - | |
37 | + | |
38 | 38 | </div> |
39 | 39 | </div> |
40 | 40 | </div> | ... | ... |
courses/templates/topic/update.html
1 | 1 | {% load static i18n list_topic_foruns permission_tags widget_tweaks professor_access list_topic_exercises course_value_field %} |
2 | 2 | |
3 | -<form class="" id="form_topic_update" method="post" action=""> | |
3 | +<form class="" id="form_topic_update_{{topic.slug}}" method="post" action=""> | |
4 | 4 | {% csrf_token %} |
5 | 5 | {% for field in form %} |
6 | 6 | <div class="form-group {% if field.errors %} has-error{% endif %}"> |
... | ... | @@ -100,15 +100,15 @@ |
100 | 100 | <div class="form-group"> |
101 | 101 | <div class="col-md-10"> |
102 | 102 | <a href="javascript:topic.get('{% url 'course:view_topic' topic.slug %}','#content_topic_{{topic.slug}}','true');" class="btn btn-raised btn-default">{% trans 'Back' %}</a> |
103 | - <button type="submite" form="form_topic_update" class="btn btn-raised btn-primary">{% trans 'Submit' %}</a> | |
103 | + <button type="submite" form="form_topic_update_{{topic.slug}}" class="btn btn-raised btn-primary">{% trans 'Submit' %}</a> | |
104 | 104 | </div> |
105 | 105 | </div> |
106 | 106 | |
107 | 107 | <script type="text/javascript"> |
108 | 108 | $(document).ready(function() { |
109 | - $('#id_description').summernote(); | |
109 | + $('#id_description').summernote({height:250}); | |
110 | 110 | }); |
111 | - $("#form_topic_update").submit(function(event) { | |
111 | + $("#form_topic_update_{{topic.slug}}").submit(function(event) { | |
112 | 112 | topic.post("{% url 'course:update_topic' topic.slug %}",$(this).serialize(), '#content_topic_{{topic.slug}}'); |
113 | 113 | event.preventDefault(); |
114 | 114 | }); | ... | ... |
courses/views.py
... | ... | @@ -331,7 +331,7 @@ class CourseView(LoginRequiredMixin, LogMixin, NotificationMixin, generic.Detail |
331 | 331 | model = Course |
332 | 332 | context_object_name = 'course' |
333 | 333 | template_name = 'course/view.html' |
334 | - | |
334 | + | |
335 | 335 | |
336 | 336 | def get_context_data(self, **kwargs): |
337 | 337 | subjects = None | ... | ... |