Skip to content

[WIP] Remove angular grid code #9543

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 4 additions & 10 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1380,16 +1380,10 @@ def replace_gtl_main_div(_options = {})
if layout_uses_listnav?
page.replace(:listnav_div, :partial => "layouts/listnav") # Replace accordion, if list_nav_div is there
end
if @grid_hash
page.replace_html("list_grid", :partial => "layouts/list_grid", :locals => {:options => grid_options, :js_options => js_options})
# Reset the center buttons
page << "miqGridOnCheck();"
else
# No grid, replace the gtl div
# Replace the main div area contents
page.replace_html("main_div", :partial => "layouts/gtl")
page << "$('#adv_div').slideUp(0.3);" if params[:entry]
end
# No grid, replace the gtl div
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to mention grid in the comment either now

# Replace the main div area contents
page.replace_html("main_div", :partial => "layouts/gtl")
page << "$('#adv_div').slideUp(0.3);" if params[:entry]
end
end

Expand Down
1 change: 0 additions & 1 deletion app/controllers/infra_networking_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ def replace_right_cell(options = {})
partial_locals = {:controller =>'infra_networking'}
if partial == 'layouts/x_gtl'
partial_locals[:action_url] = @lastaction
presenter[:parent_id] = @record.id # Set parent rec id for JS function miqGridSort to build URL
presenter[:parent_class] = params[:controller] # Set parent class for URL also
end
presenter.update(:main_div, r[:partial => partial, :locals => partial_locals])
Expand Down
4 changes: 0 additions & 4 deletions app/controllers/vm_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1001,10 +1001,6 @@ def replace_right_cell(options = {})
partial_locals = { :controller => 'vm' }
if partial == 'layouts/x_gtl'
partial_locals[:action_url] = @lastaction

# Set parent record id & class for JS function miqGridSort to build URL
presenter[:parent_id] = @record.id
presenter[:parent_class] = params[:controller]
end
presenter.update(:main_div, r[:partial => partial, :locals => partial_locals])

Expand Down
1 change: 0 additions & 1 deletion app/javascript/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"miqSparkleOn": true,
"miqToggleUserOptions": true,
"miqTreeActivateNode": true,
"miqOrderService": true,
"miqQueueReport": true
},
"extends": ["airbnb", "plugin:jest/recommended"],
Expand Down
1 change: 0 additions & 1 deletion app/javascript/oldjs/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ require('./miq_c3_config.js');
require('./miq_ujs_bindings.js');
require('./miq_tree.js');
require('./miq_formatters.js');
require('./miq_grid.js');
require('./miq_list_grid.js');
require('./miq_toolbar.js');
require('./miq_c3.js');
Expand Down
70 changes: 18 additions & 52 deletions app/javascript/oldjs/miq_application.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global add_flash getChartColumnDataValues getChartFormatedValue miqBrowserDetect miqExpressionPrefill miqFlashLater miqFlashSaved miqGridCheckAll miqGridGetCheckedRows miqMenu miqTreeObject miqValueStylePrefill recalculateChartYAxisLabels */
/* global add_flash getChartColumnDataValues getChartFormatedValue miqBrowserDetect miqExpressionPrefill miqFlashLater miqFlashSaved miqMenu miqTreeObject miqValueStylePrefill recalculateChartYAxisLabels */

// MIQ specific JS functions

Expand Down Expand Up @@ -351,40 +351,6 @@ window.miqValidateButtons = function(h_or_s, prefix) {
}
};

// update all checkboxes on a form when the masterToggle checkbox is changed
// parms: button_div=<id of div with buttons to update>
window.miqUpdateAllCheckboxes = function(button_div) {
if (!miqDomElementExists('masterToggle')) {
return;
}

const state = $('#masterToggle').prop('checked');

if (ManageIQ.grids.gtl_list_grid) {
miqGridCheckAll(state);
const crows = miqGridGetCheckedRows();

ManageIQ.gridChecks = crows;
miqSetButtons(crows.length, button_div);
} else if ($('input.listcheckbox').length) {
// No list_grid on the screen
const cbs = $('input.listcheckbox')
.prop('checked', state)
.trigger('change');

miqUpdateButtons(cbs[0], button_div);
} else if ($("input[id^='storage_cb']").length) {
// to handle check/uncheck all for C&U collection
$("input[id^='storage_cb']")
.prop('checked', state)
.trigger('change');
miqJqueryRequest(miqPassFields(
'/configuration/form_field_changed',
{ storage_cb_all: state }
));
}
};

// Update buttons based on number of checkboxes that are checked
// parms: obj=<checkbox element>, button_div=<id of div with buttons to update>
window.miqUpdateButtons = function(obj, button_div) {
Expand Down Expand Up @@ -439,22 +405,22 @@ window.DoNav = function(theUrl) {
};

// Routines to get the size of the window
window.miqResetSizeTimer = function() {
const height = window.innerHeight;
const offset = 427;
let h = height - offset;

if (h < 200) {
h = 200;
}

// Adjust certain elements, if present
if (miqDomElementExists('list_grid')) {
$('#list_grid').css({ height: `${h}px` });
} else if (miqDomElementExists('logview')) {
$('#logview').css({ height: `${h}px` });
}
};
// window.miqResetSizeTimer = function() {
// const height = window.innerHeight;
// const offset = 427;
// let h = height - offset;

// if (h < 200) {
// h = 200;
// }

// // Adjust certain elements, if present
// if (miqDomElementExists('list_grid')) {
// $('#list_grid').css({ height: `${h}px` });
// } else if (miqDomElementExists('logview')) {
// $('#logview').css({ height: `${h}px` });
// }
// };

// Pass fields to server given a URL and fields in name/value pairs
window.miqPassFields = function(url, args) {
Expand Down Expand Up @@ -1460,7 +1426,7 @@ $(() => {

$(window).on('resize', miqInitAccordions);
$(window).on('resize', miqInitMainContent);
$(window).on('resize', _.debounce(miqResetSizeTimer, 1000));
// $(window).on('resize', _.debounce(miqResetSizeTimer, 1000));

check_for_ellipsis();
});
Expand Down
11 changes: 5 additions & 6 deletions app/javascript/oldjs/miq_global.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
// global variables
if (!window.ManageIQ) {
window.ManageIQ = {
actionUrl: null, // action URL used in JS function miqGridSort
afterOnload: null, // JS code to be evaluated after onload
angular: {
app: null, // angular application
eventNotificationsData: null, // used by the notification drawer
rxSubject: null, // an observable
scope: null, // a scope which will have .angularForm after loading, for miqCheckForChanges
rxSubject: null, // an observable
scope: null, // a scope which will have .angularForm after loading, for miqCheckForChanges
},
asynchronous_notifications: false, // disabled by default, server overrides it in application.html.haml
browser: null, // browser name
calendar: { // TODO about to be removed
calDateFrom: null, // to limit calendar starting
calDateTo: null, // to limit calendar ending
calSkipDays: null, // to disable specific days of week
calSkipDays: null, // to disable specific days of week
},
changes: null, // indicate if there are unsaved changes
charts: {
Expand Down Expand Up @@ -49,13 +48,13 @@ if (!window.ManageIQ) {
i18n: {
mark_translated_strings: false,
},
logoutInProgress: false, // prevent redirectLogin *during* logout and group change
logoutInProgress: false, // prevent redirectLogin *during* logout and group change
menu: [],
mouse: {
x: null, // mouse X coordinate for popup menu
y: null, // mouse Y coordinate for popup menu
},
move: { //methods to move elements between Arrays or in an Array
move: { // methods to move elements between Arrays or in an Array
},
noCollapseEvent: false, // enable/disable events fired after collapsing an accordion
observe: { // keeping track of data-miq_observe requests
Expand Down
47 changes: 0 additions & 47 deletions app/javascript/oldjs/miq_grid.js

This file was deleted.

102 changes: 1 addition & 101 deletions app/javascript/oldjs/miq_list_grid.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,4 @@
/* global DoNav miqDomElementExists miqJqueryRequest miqSetButtons miqUpdateButtons */

// Handle row click (ajax or normal html trans)
window.miqRowClick = function(row_id, row_url, row_url_ajax) {
if (!row_url) {
return;
}

if (row_url_ajax) {
miqJqueryRequest(row_url + row_id, { beforeSend: true, complete: true });
} else {
DoNav(row_url + row_id);
}
};

window.checkboxItemId = function($elem) {
const val = $elem.val();
const name = $elem.attr('name');

if (_.startsWith(name, 'check_')) {
return name.substr(6);
}

return val;
};

// returns a list of checked row ids
window.miqGridGetCheckedRows = function(grid) {
grid = grid || 'list_grid';
const crows = [];

$(`#${grid} .list-grid-checkbox`).each((_idx, elem) => {
if (!$(elem).prop('checked')) {
return;
}

const item_id = checkboxItemId($(elem));
crows.push(item_id);
});

return crows;
};

// checks/unchecks all grid rows
window.miqGridCheckAll = function(state, grid) {
grid = grid || 'list_grid';
state = !!state;

$(`#${grid} .list-grid-checkbox`)
.prop('checked', state)
.trigger('change');
};

// Order a service from the catalog list view
window.miqOrderService = function(id) {
const url = `/${ManageIQ.controller}/x_button/${id}?pressed=svc_catalog_provision`;
miqJqueryRequest(url, { beforeSend: true, complete: true });
};

// Needed for optimization page queue report button
window.miqQueueReport = function(id) {
const url = `/optimization/queue_report/${id}`;
window.miqSparkleOn();
Expand All @@ -68,45 +10,3 @@ window.miqQueueReport = function(id) {
})
.catch(() => window.miqSparkleOff());
};

// Handle checkbox
window.miqGridOnCheck = function(elem, button_div, grid) {
if (elem) {
miqUpdateButtons(elem, button_div);
}

const crows = miqGridGetCheckedRows(grid);
ManageIQ.gridChecks = crows;

miqSetButtons(crows.length, 'center_tb');
};

// Handle sort
window.miqGetSortUrl = function(col_id) {
let controller = null;
const action = ManageIQ.actionUrl;
let id = null;

if (action === 'sort_ds_grid') {
controller = 'miq_request';
} else if (ManageIQ.record.parentId !== null) {
controller = ManageIQ.record.parentClass;
id = ManageIQ.record.parentId;
}

let url = action;
if (controller) {
url = `/${controller}/${url}`;
}
if (id && (url.indexOf(id) < 0)) {
url = `${url}/${id}`;
}

url = `${url}?sortby=${col_id}&${window.location.search.substring(1)}`;
return url;
};

window.miqGridSort = function(col_id) {
const url = miqGetSortUrl(col_id);
miqJqueryRequest(url, { beforeSend: true, complete: true });
};
Loading