ci: add prettier to pre-commit (backport #40206) (#40362)

* ci: add prettier to pre-commit

(cherry picked from commit 2c16036ef3)

* style: format js files

---------

Co-authored-by: barredterra <14891507+barredterra@users.noreply.github.com>
Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
mergify[bot]
2024-03-11 10:47:18 +05:30
committed by GitHub
parent 5f789d9abe
commit 7d3d2eb928
572 changed files with 24271 additions and 21331 deletions

View File

@@ -1,120 +1,117 @@
frappe.ready(function() {
$('.task-status-switch').on('click', function() {
frappe.ready(function () {
$(".task-status-switch").on("click", function () {
var $btn = $(this);
if($btn.attr('data-status')==='Open') {
reload_items('completed', 'task', $btn);
if ($btn.attr("data-status") === "Open") {
reload_items("completed", "task", $btn);
} else {
reload_items('open', 'task', $btn);
reload_items("open", "task", $btn);
}
})
});
$('.issue-status-switch').on('click', function() {
$(".issue-status-switch").on("click", function () {
var $btn = $(this);
if($btn.attr('data-status')==='Open') {
reload_items('completed', 'issue', $btn);
if ($btn.attr("data-status") === "Open") {
reload_items("completed", "issue", $btn);
} else {
reload_items('open', 'issue', $btn);
reload_items("open", "issue", $btn);
}
})
});
var start = 10;
$(".more-tasks").click(function() {
more_items('task', true);
$(".more-tasks").click(function () {
more_items("task", true);
});
$(".more-issues").click(function() {
more_items('issue', true);
$(".more-issues").click(function () {
more_items("issue", true);
});
$(".more-timelogs").click(function() {
more_items('timelog', false);
$(".more-timelogs").click(function () {
more_items("timelog", false);
});
$(".more-timelines").click(function() {
more_items('timeline', false);
$(".more-timelines").click(function () {
more_items("timeline", false);
});
$(".file-size").each(function() {
$(".file-size").each(function () {
$(this).text(frappe.form.formatters.FileSize($(this).text()));
});
var reload_items = function(item_status, item, $btn) {
var reload_items = function (item_status, item, $btn) {
$.ajax({
method: "GET",
url: "/",
dataType: "json",
data: {
cmd: "erpnext.templates.pages.projects.get_"+ item +"_html",
project: '{{ doc.name }}',
cmd: "erpnext.templates.pages.projects.get_" + item + "_html",
project: "{{ doc.name }}",
item_status: item_status,
},
success: function(data) {
if(typeof data.message == 'undefined') {
$('.project-'+ item).html("No "+ item_status +" "+ item);
$(".more-"+ item).toggle(false);
success: function (data) {
if (typeof data.message == "undefined") {
$(".project-" + item).html("No " + item_status + " " + item);
$(".more-" + item).toggle(false);
}
$('.project-'+ item).html(data.message);
$(".more-"+ item).toggle(true);
$(".project-" + item).html(data.message);
$(".more-" + item).toggle(true);
// update status
if(item_status==='open') {
$btn.html(__('Show Completed')).attr('data-status', 'Open');
if (item_status === "open") {
$btn.html(__("Show Completed")).attr("data-status", "Open");
} else {
$btn.html(__('Show Open')).attr('data-status', 'Completed');
$btn.html(__("Show Open")).attr("data-status", "Completed");
}
}
},
});
};
}
var more_items = function(item, item_status){
if(item_status) {
item_status = $('.project-'+ item +'-section .btn-group .bold').hasClass('btn-completed-'+ item)
? 'completed' : 'open';
var more_items = function (item, item_status) {
if (item_status) {
item_status = $(".project-" + item + "-section .btn-group .bold").hasClass(
"btn-completed-" + item
)
? "completed"
: "open";
}
$.ajax({
method: "GET",
url: "/",
dataType: "json",
data: {
cmd: "erpnext.templates.pages.projects.get_"+ item +"_html",
project: '{{ doc.name }}',
cmd: "erpnext.templates.pages.projects.get_" + item + "_html",
project: "{{ doc.name }}",
start: start,
item_status: item_status,
},
success: function(data) {
$(data.message).appendTo('.project-'+ item);
if(typeof data.message == 'undefined') {
$(".more-"+ item).toggle(false);
success: function (data) {
$(data.message).appendTo(".project-" + item);
if (typeof data.message == "undefined") {
$(".more-" + item).toggle(false);
}
start = start+10;
}
start = start + 10;
},
});
}
};
var close_item = function(item, item_name){
var close_item = function (item, item_name) {
var args = {
project: '{{ doc.name }}',
project: "{{ doc.name }}",
item_name: item_name,
}
};
frappe.call({
btn: this,
type: "POST",
method: "erpnext.templates.pages.projects.set_"+ item +"_status",
method: "erpnext.templates.pages.projects.set_" + item + "_status",
args: args,
callback: function(r) {
if(r.exc) {
if(r._server_messages)
frappe.msgprint(r._server_messages);
callback: function (r) {
if (r.exc) {
if (r._server_messages) frappe.msgprint(r._server_messages);
} else {
$(this).remove();
}
}
})
},
});
return false;
}
};
});