Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect Manager: Fix Broken UI in Cloud SDK #2721

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.coral-InputGroup-input {
width: 300px;
}


.acs-tooltip {
margin-left: 160px !important;
Expand All @@ -11,3 +9,4 @@
white-space: pre-wrap;
font-family: 'Courier New', Courier, monospace
}

Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
(function($, $document) {
"use strict";
"use strict";

var registry = $(window).adaptTo("foundation-registry");
var DIALOG_FORM_SELECTOR = "#fn-acsCommons-save_redirects";
var DIALOG_SELECTOR = "#editRuleDialog";
var TABLE_SELECTOR = "#edit-redirect-coral-table";

function showEditDialog() {
var dialog = document.querySelector('#demoDialog');
var dialog = document.querySelector(DIALOG_SELECTOR);
dialog.show();
}



[
'coral-table:change',
'coral-table:beforecolumnsort',
Expand All @@ -21,22 +25,22 @@
'coral-table:beforeroworder',
]
.forEach(function(eventName) {
$document.on(eventName, '#edit-redirect-coral-table', function(e) {
$document.on(eventName, TABLE_SELECTOR, function(e) {
if(e.type=='coral-table:beforeroworder') {
var thisElement = $(this);
var rowIndex = e.detail.row.rowIndex;
var beforeRow = e.detail.before;
var beforeIndex;
if(!beforeRow) {
beforeIndex = $('#edit-redirect-coral-table').get(0)._items.length + 1;
beforeIndex = $(TABLE_SELECTOR).get(0)._items.length + 1;
} else {
beforeIndex =e.detail.before.rowIndex;
}
var source = $(e.detail.row).find('.source').data('value');
var target = $(e.detail.row).find('.target').data('value');
updateFormData($(e.detail.row));

var $form = $("form.acs-redirect-rule-form");
var $form = $(DIALOG_FORM_SELECTOR);
var data = $form.serialize();
var nextIndex = beforeIndex - 1;
if(rowIndex == beforeIndex || rowIndex == nextIndex) {
Expand All @@ -60,28 +64,14 @@
});
});

$(document).on("click", ".cq-dialog-submit", function (e) {
$(document).on("click", "button[icon='delete']", function (e) {
e.preventDefault();
var $form = $(this).closest('form');
var cmd = $(this).attr('cmd');
var formId = $(this).attr('form');
var $form = $("#" + formId);
var buttonId = $(this).attr('id');
var cmd = buttonId && buttonId.startsWith(":") ? buttonId : null;
var data = $form.serialize();
var command;
if(cmd){
if(cmd.indexOf(":order") === 0){
var dialog = $('#demoDialog');
var id = dialog.find('.acs-redirect-rule-form').attr('id');
var editRedirectTable = $('#edit-redirect-coral-table');
var $rows = editRedirectTable.find('tr');
var tr = editRedirectTable.find('#'+id);
var idx = tr.index();
if(cmd.indexOf("$prev") > 0){
cmd = cmd.replace("$prev", idx > 0 ? idx-1 : 0);
command = 'prev';
} else {
cmd = cmd.replace("$next", idx < $rows.length ? idx+1 : $rows.length);
command = 'next';
}
}
data += "&" + cmd;
}
var message = $(this).attr('alert');
Expand All @@ -91,43 +81,43 @@
data: data,
async: false
}).done(function(response /*json response from the Sling POST servlet*/){

var dialog = $('#demoDialog');
var id = dialog.find('.acs-redirect-rule-form').attr('id');
var dialog = $(DIALOG_SELECTOR);
dialog.find('.close-dialog-box').click();
var editRedirectTable = $('#edit-redirect-coral-table');

if(command == 'prev') {
var trPrev = editRedirectTable.find('#'+id);
if(trPrev.prev()) {
$('#'+id).prev().before($('#'+id));
}
} else if(command == 'next') {
var tr = editRedirectTable.find('#'+id);
if(tr.next()) {
$('#'+id).next().after($('#'+id));
}
} else if(cmd == ':operation=delete'){
$('#'+id).remove();
} else {
var redirectPath = response.path;
// redirectId is the node name, i.e. the last segment of the path
var redirectId = redirectPath.substring(redirectPath.lastIndexOf('/') + 1);
// fetch the table row and update/insert it in the table
$.ajax({

var ruleId = $form.attr('ruleId');

$('#'+ruleId).remove();
});
return false;
});

registry.register("foundation.form.response.ui.success", {
name: "acs.redirects.update",
handler: function(form, config, response, textStatus, xhr) {
var dialog = $(DIALOG_SELECTOR);
dialog.find('.close-dialog-box').click();

var redirectPath = response.path;
// redirectId is the node name, i.e. the last segment of the path
var redirectId = redirectPath.substring(redirectPath.lastIndexOf('/') + 1);

// fetch the table row and update/insert it in the table
$.ajax({
url: redirectPath + ".html"
}).done(function(trHtml){
if(response.isCreate){
editRedirectTable.find("tbody")[0].insertAdjacentHTML("beforeend", trHtml);
var editRedirectTable = $(TABLE_SELECTOR);
var tr = editRedirectTable.find("tbody")[0].appendChild(document.createElement('tr'));
$(tr).replaceWith(trHtml);
} else {
$('#'+redirectId).replaceWith(trHtml);
}
});
}
});
return false;
});
var ui = $(window).adaptTo('foundation-ui');
ui.clearWait();

});
}
});
$(document).on("click", ".cq-dialog-upload", function (e) {
var $form = $(this).closest('form');
var data = new FormData($form[0]);
Expand Down Expand Up @@ -185,17 +175,18 @@
var note = tr.find('.note').data('value');
var statusCode = tr.find('.statusCode').data('value');
var untilDate = tr.find('.untilDate').data('value');
var cloudFront = tr.find('.cloudFront').html();
var dialog = $('#demoDialog');
dialog.find('.source').val(source);
dialog.find('.target').val(target);

var form = $('#editRuleDialog').find("form");
form[0].reset();
if(source) form.find('foundation-autocomplete[name="./source"]').val(source);
if(target) form.find('foundation-autocomplete[name="./target"]').val(target);
var select = $('#status-code-select-box').get(0);
select.value =statusCode;
dialog.find('.untilDate').val(untilDate);
dialog.find('.note').val(note);
form.find('coral-datepicker[name="./untilDate"]').val(untilDate);
form.find('input[name="./note"]').val(note);

dialog.find('.acs-redirect-rule-form').attr('action', path);
dialog.find('.acs-redirect-rule-form').attr('id', name);
form.attr('action', path);
form.attr('ruleId', name);
}

$(document).on("click", ".edit-redirect-rule", function (e) {
Expand All @@ -214,22 +205,6 @@
});


$("#status-code-select-box").change(function (e) {
var val = $(e.target).find(":selected").val();
if(val == 301){
$("#until-date-picker").val("");

var dialog = new Coral.Dialog();
dialog.header.innerHTML = 'Warning';
dialog.content.innerHTML = "Permanent Redirect Selected" +
"<p>The HTTP 301 status code is cached in browsers with no expiry date and cannot be reverted.<br>"+
"The Until Date was cleared because once 301 is applied, it is forever</p>";
dialog.footer.innerHTML = '<button is="coral-button" variant="primary" coral-close>Ok</button>';
dialog.variant = 'warning';
dialog.show();
}
});


$(document).ready(function() {
var panelList = document.querySelector('#main-panel-1');
Expand All @@ -255,6 +230,23 @@
});
});

$("#status-code-select-box").change(function (e) {
var val = $(e.target).find(":selected").val();
if(val == 301){
$("#until-date-picker").val("");

var dialog = new Coral.Dialog();
dialog.header.innerHTML = 'Warning';
dialog.content.innerHTML = "Permanent Redirect Selected" +
"<p>The HTTP 301 status code is cached in browsers with no expiry date and cannot be reverted.<br>"+
"The Until Date was cleared because once 301 is applied, it is forever</p>";
dialog.footer.innerHTML = '<button is="coral-button" variant="primary" coral-close>Ok</button>';
dialog.variant = 'warning';
dialog.show();
}
});


});

$(document).on("click", "#addConfigurationButton", function (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
<betty-breadcrumbs-item data-granite-collection-navigator-href="/apps/acs-commons/content/redirect-manager/redirects.html">Redirect Configurations</betty-breadcrumbs-item>
</betty-breadcrumbs>
</betty-titlebar-title>
</betty-titlebar-title>
<betty-titlebar-primary></betty-titlebar-primary>
<betty-titlebar-secondary>
</betty-titlebar-secondary>
Expand All @@ -62,7 +61,6 @@
<coral-tab>Publish</coral-tab>
</coral-tablist>
<coral-panelstack id="main-panel-1" >
<sly data-sly-include="./redirect-rule/redirect-rule.html"></sly>
<coral-panel class="coral-Well">
<div class="coral-Form-fieldwrapper">
<button class="coral-Button coral-Button--primary new-redirect-rule"
Expand All @@ -72,12 +70,11 @@
<section class="coral-Form coral-Form--vertical">
<div clas="coral-Form-fieldset">
<br>
<div class="coral-Form-fieldwrapper" style="width: 100%; display: inline-block;">
<input is="coral-textfield" id="redirect-search-box" class="coral-Form-field" placeholder="Search" name="name" labelledby="label-vertical-textfield-0">
</div>
<coral-search placeholder="Search" class="coral-Form-field" name="name" id="redirect-search-box"/>
</coral-search>
</div>

<table is="coral-table" id="edit-redirect-coral-table" orderable style="height:500px">
<table is="coral-table" id="edit-redirect-coral-table" class="table-sticky" orderable style="height:500px">
<colgroup>
<col is="coral-table-column">
<col is="coral-table-column">
Expand Down Expand Up @@ -164,6 +161,9 @@ <h2 class="coral-Heading coral-Heading--2">Import Redirect Map</h2>
</coral-panel>
</coral-panelstack>
</coral-tabview>
<sly data-sly-list="${resource.getChildren}">
<sly data-sly-resource="${item.path}"></sly>
</sly>

</div>
</div>
Expand Down

This file was deleted.

Loading