All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ui.static.topic.editTopic.js Maven / Gradle / Ivy

There is a newer version: 0.8.0
Show newest version
$(document).ready(function () {
    $("#edit-btn").click(editTopic);
});

function editTopic() {
    let topicDescription = extractTopicDescription();
    let validateErrors = validateTopicDescription(topicDescription);
    let updateMsg = extractUpdateMessage();
    if (updateMsg.trim() === "") {
        validateErrors.push("Please specify update reason");
    }
    if (validateErrors.length > 0) {
        showOpError("Failed validation", validateErrors.join("\n"));
        return;
    }
    updateMsg = appendJiraIssuesIfAny(updateMsg, topicDescription.description);
    showOpProgress("Editing topic...");
    $
        .ajax("api/topics?message=" + encodeURI(updateMsg) + "&" + targetBranchUriParam(), {
            method: "PUT",
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(topicDescription)
        })
        .done(function () {
            location.href = urlFor("topics.showTopic", {topicName: topicDescription.name});
        })
        .fail(function (error) {
            let errorMsg = extractErrMsg(error);
            showOpError(errorMsg);
        });
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy