33# fixed problems with wishlist
This commit is contained in:
parent
21e9f74911
commit
b9f93a6dc5
@ -229,11 +229,11 @@
|
||||
<a href="{% url 'jobs:single_job' job.slug job.pk %}" class="btn btn-primary py-2 mr-1">Apply Job</a>
|
||||
|
||||
{% if job.id in wish_list %}
|
||||
<a href="javascripts:void(0);" id="jobwl{{ job.id }}" title="Remove from my wish list" onclick="removefrommywishlist({{ job.id }})" class="btn btn-danger rounded-circle btn-favorite d-flex align-items-center">
|
||||
<a href="javascripts:void(0);" id="jobwl{{ job.id }}" title="Remove from my wish list" onclick="addorremove({{ job.id }})" class="btn btn-danger rounded-circle btn-favorite d-flex align-items-center">
|
||||
<span class="icon-heart"></span>
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="javascripts:void(0);" id="jobwl{{ job.id }}" title="Add to my wish list" onclick="addtomywishlist({{ job.id }})" class="btn btn-primary rounded-circle btn-favorite d-flex align-items-center">
|
||||
<a href="javascripts:void(0);" id="jobwl{{ job.id }}" title="Add to my wish list" onclick="addorremove({{ job.id }})" class="btn btn-primary rounded-circle btn-favorite d-flex align-items-center">
|
||||
<span class="icon-heart"></span>
|
||||
</a>
|
||||
{% endif %}
|
||||
@ -478,13 +478,16 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script type="text/javascript">
|
||||
function addtomywishlist(id) {
|
||||
{% if user.is_authenticated and user.is_employee%}
|
||||
<script type="text/javascript">
|
||||
function addorremove(id) {
|
||||
if (id){
|
||||
var wishlist = $('#jobwl' + id).data('wl');
|
||||
if(wishlist == 0) {
|
||||
$.ajax({
|
||||
url:"/users/add-wishlist/" + id,
|
||||
method:"GET",
|
||||
success:function () {
|
||||
url: "/users/add-wishlist/" + id,
|
||||
method: "GET",
|
||||
success: function () {
|
||||
$('#jobwl' + id).removeClass('btn-primary').addClass('btn-danger')
|
||||
const Toast = Swal.mixin({
|
||||
toast: true,
|
||||
@ -502,13 +505,10 @@
|
||||
icon: 'success',
|
||||
title: 'Added'
|
||||
})
|
||||
$('#jobwl' + id).data('wl', 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function removefrommywishlist(id) {
|
||||
if (id){
|
||||
}else{
|
||||
$.ajax({
|
||||
url:"/users/remove-from-wishlist/" + id,
|
||||
method:"GET",
|
||||
@ -530,10 +530,39 @@
|
||||
icon: 'error',
|
||||
title: 'Removed'
|
||||
})
|
||||
$('#jobwl' + id).data('wl', 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
}
|
||||
</script>
|
||||
{% else %}
|
||||
<script type="text/javascript">
|
||||
function addtomywishlist(id) {
|
||||
if (id){
|
||||
$.ajax({
|
||||
success:function () {
|
||||
const Toast = Swal.mixin({
|
||||
toast: true,
|
||||
position: 'top',
|
||||
showConfirmButton: true,
|
||||
timer: 3000,
|
||||
timerProgressBar: true,
|
||||
didOpen: (toast) => {
|
||||
toast.addEventListener('mouseenter', Swal.stopTimer)
|
||||
toast.addEventListener('mouseleave', Swal.resumeTimer)
|
||||
}
|
||||
})
|
||||
|
||||
Toast.fire({
|
||||
icon: 'error',
|
||||
title: 'You are not an employee!'
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user