mirror of
https://github.com/chibicitiberiu/ytsm.git
synced 2024-02-24 05:43:31 +00:00
Finished CRUD operations for subscriptions and folders.
This commit is contained in:
@ -6,16 +6,18 @@
|
||||
{% endblock modal_title %}
|
||||
|
||||
{% block modal_content %}
|
||||
<form action="{% url 'modal_delete_folder' form.instance.pk %}" method="post">
|
||||
<form action="{% url 'modal_delete_folder' object.id %}" method="post">
|
||||
{% csrf_token %}
|
||||
{{ block.super }}
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
{% block modal_body %}
|
||||
{% crispy form %}
|
||||
<p>Are you sure you want to delete folder "{{ object }}" and all its subfolders?</p>
|
||||
{{ form | crispy }}
|
||||
{% endblock modal_body %}
|
||||
|
||||
{% block modal_footer %}
|
||||
<input class="btn btn-danger" type="submit" value="Save" aria-label="Delete">
|
||||
<input class="btn btn-danger" type="submit" value="Delete" aria-label="Delete">
|
||||
<input class="btn btn-secondary" type="button" value="Cancel" data-dismiss="modal" aria-label="Cancel">
|
||||
{% endblock modal_footer %}
|
@ -28,6 +28,7 @@
|
||||
|
||||
{% block modal_footer_wrapper %}
|
||||
<div class="modal-footer">
|
||||
<div id="modal-loading-ring" class="loading-dual-ring-small mr-auto" style="display: none;"></div>
|
||||
{% block modal_footer %}
|
||||
{% endblock modal_footer %}
|
||||
</div>
|
||||
|
@ -0,0 +1,21 @@
|
||||
{% extends 'YtManagerApp/controls/modal.html' %}
|
||||
{% load crispy_forms_tags %}
|
||||
|
||||
{% block modal_title %}
|
||||
New subscription
|
||||
{% endblock modal_title %}
|
||||
|
||||
{% block modal_content %}
|
||||
<form action="{% url 'modal_create_subscription' %}" method="post">
|
||||
{{ block.super }}
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
{% block modal_body %}
|
||||
{% crispy form %}
|
||||
{% endblock modal_body %}
|
||||
|
||||
{% block modal_footer %}
|
||||
<input class="btn btn-primary" type="submit" value="Create">
|
||||
<input class="btn btn-secondary" type="button" value="Cancel" data-dismiss="modal" aria-label="Cancel">
|
||||
{% endblock modal_footer %}
|
@ -0,0 +1,23 @@
|
||||
{% extends 'YtManagerApp/controls/modal.html' %}
|
||||
{% load crispy_forms_tags %}
|
||||
|
||||
{% block modal_title %}
|
||||
Delete subscription
|
||||
{% endblock modal_title %}
|
||||
|
||||
{% block modal_content %}
|
||||
<form action="{% url 'modal_delete_folder' object.id %}" method="post">
|
||||
{% csrf_token %}
|
||||
{{ block.super }}
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
{% block modal_body %}
|
||||
<p>Are you sure you want to delete subscription "{{ object }}"?</p>
|
||||
{{ form | crispy }}
|
||||
{% endblock modal_body %}
|
||||
|
||||
{% block modal_footer %}
|
||||
<input class="btn btn-danger" type="submit" value="Delete" aria-label="Delete">
|
||||
<input class="btn btn-secondary" type="button" value="Cancel" data-dismiss="modal" aria-label="Cancel">
|
||||
{% endblock modal_footer %}
|
@ -1,45 +0,0 @@
|
||||
<div id="subscriptionEditDialog" class="modal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 id="subscriptionEditDialog_Title" class="modal-title">Edit subscription</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div id="subscriptionEditDialog_Loading" class="modal-body">
|
||||
<div class="loading-dual-ring"></div>
|
||||
</div>
|
||||
<div id="subscriptionEditDialog_Error"></div>
|
||||
<form id="subscriptionEditDialog_Form" action="{% url 'ajax_edit_subscription' %}" method="post">
|
||||
<div class="modal-body">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" id="subscriptionEditDialog_Id" name="id" value="#">
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3" for="subscriptionEditDialog_Url">Link:</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" class="form-control" id="subscriptionEditDialog_Url" name="url" placeholder="Subscription URL (playlist, channel)">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3" for="subscriptionEditDialog_Name">Name:</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" class="form-control" id="subscriptionEditDialog_Name" name="name" placeholder="Subscription name">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3" for="subscriptionEditDialog_Parent">Parent subscription</label>
|
||||
<div class="col-sm-9">
|
||||
<select class="form-control" id="subscriptionEditDialog_Parent" name="parent">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="subscriptionEditDialog_Submit" type="submit" class="btn btn-primary">Submit</button>
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,21 @@
|
||||
{% extends 'YtManagerApp/controls/modal.html' %}
|
||||
{% load crispy_forms_tags %}
|
||||
|
||||
{% block modal_title %}
|
||||
Edit subscription
|
||||
{% endblock modal_title %}
|
||||
|
||||
{% block modal_content %}
|
||||
<form action="{% url 'modal_update_subscription' form.instance.pk %}" method="post">
|
||||
{{ block.super }}
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
{% block modal_body %}
|
||||
{% crispy form %}
|
||||
{% endblock modal_body %}
|
||||
|
||||
{% block modal_footer %}
|
||||
<input class="btn btn-primary" type="submit" value="Save" aria-label="Save">
|
||||
<input class="btn btn-secondary" type="button" value="Cancel" data-dismiss="modal" aria-label="Cancel">
|
||||
{% endblock modal_footer %}
|
@ -55,6 +55,7 @@ class AjaxModal
|
||||
this.modal = null;
|
||||
this.form = null;
|
||||
this.submitCallback = null;
|
||||
this.modalLoadingRing = null;
|
||||
}
|
||||
|
||||
setSubmitCallback(callback) {
|
||||
@ -84,6 +85,7 @@ class AjaxModal
|
||||
|
||||
this.modal = this.wrapper.find('.modal');
|
||||
this.form = this.wrapper.find('form');
|
||||
this.modalLoadingRing = this.wrapper.find('#modal-loading-ring');
|
||||
|
||||
let pThis = this;
|
||||
this.form.submit(function(e) {
|
||||
@ -104,8 +106,15 @@ class AjaxModal
|
||||
})
|
||||
.fail(function() {
|
||||
pThis._submitFailed();
|
||||
})
|
||||
.always(function() {
|
||||
pThis.modalLoadingRing.fadeOut(100);
|
||||
pThis.wrapper.find(":input").prop("disabled", false);
|
||||
});
|
||||
|
||||
this.modalLoadingRing.fadeIn(200);
|
||||
this.wrapper.find(":input").prop("disabled", true);
|
||||
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
|
@ -236,11 +236,10 @@ function treeNode_Edit()
|
||||
modal.loadAndShow();
|
||||
}
|
||||
else {
|
||||
//TODO:
|
||||
//let id = node.id.replace('sub', '');
|
||||
//let modal = new AjaxModal("{ url 'modal_update_subscription' 98765 }".replace('98765', id));
|
||||
//modal.setSubmitCallback(tree_Refresh);
|
||||
//modal.loadAndShow();
|
||||
let id = node.id.replace('sub', '');
|
||||
let modal = new AjaxModal("{% url 'modal_update_subscription' 98765 %}".replace('98765', id));
|
||||
modal.setSubmitCallback(tree_Refresh);
|
||||
modal.loadAndShow();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -259,11 +258,10 @@ function treeNode_Delete()
|
||||
modal.loadAndShow();
|
||||
}
|
||||
else {
|
||||
//TODO:
|
||||
//let id = node.id.replace('sub', '');
|
||||
//let modal = new AjaxModal("{ url 'modal_delete_subscription' 98765 }".replace('98765', id));
|
||||
//modal.setSubmitCallback(tree_Refresh);
|
||||
//modal.loadAndShow();
|
||||
let id = node.id.replace('sub', '');
|
||||
let modal = new AjaxModal("{% url 'modal_delete_subscription' 98765 %}".replace('98765', id));
|
||||
modal.setSubmitCallback(tree_Refresh);
|
||||
modal.loadAndShow();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -274,7 +272,7 @@ function tree_Initialize()
|
||||
treeWrapper.jstree({
|
||||
core : {
|
||||
data : {
|
||||
url : "{% url 'ajax_index_get_tree' %}"
|
||||
url : "{% url 'ajax_get_tree' %}"
|
||||
},
|
||||
check_callback : tree_ValidateChange,
|
||||
themes : {
|
||||
@ -350,7 +348,7 @@ function videos_Reload()
|
||||
loadingDiv.fadeIn(300);
|
||||
|
||||
// Perform query
|
||||
$.post("{% url 'ajax_index_get_videos' %}", filterForm.serialize())
|
||||
$.post("{% url 'ajax_get_videos' %}", filterForm.serialize())
|
||||
.done(function (result) {
|
||||
$("#videos-wrapper").html(result);
|
||||
})
|
||||
@ -393,6 +391,11 @@ $(document).ready(function ()
|
||||
// folderEditDialog = new FolderEditDialog('#folderEditDialog');
|
||||
// subscriptionEditDialog = new SubscriptionEditDialog('#subscriptionEditDialog');
|
||||
//
|
||||
$("#btn_create_sub").on("click", function () {
|
||||
let modal = new AjaxModal("{% url 'modal_create_subscription' %}");
|
||||
modal.setSubmitCallback(tree_Refresh);
|
||||
modal.loadAndShow();
|
||||
});
|
||||
$("#btn_create_folder").on("click", function () {
|
||||
let modal = new AjaxModal("{% url 'modal_create_folder' %}");
|
||||
modal.setSubmitCallback(tree_Refresh);
|
||||
|
Reference in New Issue
Block a user