Urgent fix to the fields area to address the extra field options, and fields with 0 being removed. Added the option to add a field and not add it to the database, so it will show in the edit view but will not be stored to the database. This is to use javascript/php to use that field value, and then drop it.
This commit is contained in:
@ -114,4 +114,126 @@ $componentParams = JComponentHelper::getParams('com_componentbuilder');
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
// little script to check value and give notice
|
||||
function checkAdminBehaviour(field) {
|
||||
// get the ID
|
||||
var id = jQuery(field).attr('id');
|
||||
var target = id.split('__');
|
||||
//set the subID
|
||||
var subID = target[0]+'__'+target[1];
|
||||
// get value
|
||||
var value = jQuery('#'+subID+'__list').val();
|
||||
// set notice and do house cleaning
|
||||
if (2 == value) {
|
||||
// no database
|
||||
if (target[2] == 'list') {
|
||||
jQuery.UIkit.notify({message: Joomla.JText._('COM_COMPONENTBUILDER_ONLY_USE_THE_BNONE_DBB_OPTION_IF_YOU_ARE_PLANNING_ON_TARGETING_THIS_FIELD_WITH_JAVASCRIPTCUSTOM_PHP_TO_MOVE_ITS_VALUE_INTO_ANOTHER_FIELD_THAT_DOES_GET_SAVED_TO_THE_DATABASE'), timeout: 10000, status: 'warning', pos: 'top-right'});
|
||||
jQuery.UIkit.notify({message: Joomla.JText._('COM_COMPONENTBUILDER_THE_BNONE_DBB_OPTION_WILL_REMOVE_THIS_FIELD_FROM_BEING_SAVED_IN_THE_DATABASE'), timeout: 5000, status: 'primary', pos: 'top-right'});
|
||||
} else {
|
||||
jQuery.UIkit.notify({message: Joomla.JText._('COM_COMPONENTBUILDER_THESE_OPTIONS_ARE_NOT_AVAILABLE_TO_THE_FIELD_IF_BNONE_DBB_OPTION_IS_SELECTED'), timeout: 7000, status: 'warning', pos: 'top-right'});
|
||||
}
|
||||
// do some house cleaning
|
||||
jQuery('#'+subID+'__order_list').val(0).trigger('liszt:updated');
|
||||
jQuery('#'+subID+'__title').prop('checked', false).trigger('change');
|
||||
jQuery('#'+subID+'__alias').prop('checked', false).trigger('change');
|
||||
jQuery('#'+subID+'__sort').prop('checked', false).trigger('change');
|
||||
jQuery('#'+subID+'__search').prop('checked', false).trigger('change');
|
||||
jQuery('#'+subID+'__filter').prop('checked', false).trigger('change');
|
||||
jQuery('#'+subID+'__link').prop('checked', false).trigger('change');
|
||||
} else if (1 == value) {
|
||||
// get number of items
|
||||
var numItems = jQuery('.count-the-items1235').length + 10;
|
||||
// show in list view
|
||||
if (target[2] == 'list') {
|
||||
jQuery.UIkit.notify({message: Joomla.JText._('COM_COMPONENTBUILDER_THE_BSHOW_IN_LIST_VIEWB_OPTION_WILL_ADD_THIS_FIELD_TO_THE_ADMIN_LIST_VIEW'), timeout: 5000, status: 'primary', pos: 'top-right'});
|
||||
}
|
||||
// check if the order list already has a value
|
||||
var orderList = jQuery('#'+subID+'__order_list').val();
|
||||
if (orderList == 0) {
|
||||
// count the already set and get the next number available
|
||||
var listviewNumber = fanAsgfdSffsNumber(subID.replace(/\d+/g, ''), numItems);
|
||||
// update the position
|
||||
jQuery('#'+subID+'__order_list').val(listviewNumber).trigger('liszt:updated');
|
||||
}
|
||||
} else {
|
||||
// do some house cleaning
|
||||
jQuery('#'+subID+'__order_list').val(0).trigger('liszt:updated');
|
||||
jQuery('#'+subID+'__sort').prop('checked', false).trigger('change');
|
||||
jQuery('#'+subID+'__filter').prop('checked', false).trigger('change');
|
||||
jQuery('#'+subID+'__link').prop('checked', false).trigger('change');
|
||||
}
|
||||
}
|
||||
|
||||
// count the already set and get the next number available
|
||||
function fanAsgfdSffsNumber(targetForm, numItems) {
|
||||
var i;
|
||||
// no check all the order values already set so to fill in the caps
|
||||
var numbers = [];
|
||||
for (i = 0; i < numItems; i++) { // for now this is the number of field we should check
|
||||
// build ID
|
||||
var id_check = targetForm+i+'__order_list';
|
||||
// first check if Id is on page
|
||||
if (jQuery("#"+id_check).length) {
|
||||
// get the property value
|
||||
var tmp = jQuery("#"+id_check+" option:selected").val();
|
||||
// now validate
|
||||
if (tmp >= 1) {
|
||||
numbers.push(parseInt(tmp));
|
||||
}
|
||||
}
|
||||
}
|
||||
// check that there are actually some set
|
||||
if (numbers.length) {
|
||||
// sort the array
|
||||
numbers.sort(fanAsgfdSffsSort);
|
||||
// get the absent values
|
||||
var absent = fanAsgfdSffsAbsent(numbers);
|
||||
// check if an absent value was found
|
||||
if (absent.length) {
|
||||
// sort the array (just to be safe)
|
||||
absent.sort(fanAsgfdSffsSort);
|
||||
// return lowest found value
|
||||
return absent[0];
|
||||
}
|
||||
}
|
||||
// since no absent value was found add to next available option
|
||||
var total = 0;
|
||||
for (i = 0; i < numItems; i++) { // for now this is the number of field we should check
|
||||
// build ID
|
||||
var id_check = targetForm+i+'__list';
|
||||
// first check if Id is on page
|
||||
if (jQuery("#"+id_check).length) {
|
||||
// get the property value
|
||||
var tmp = jQuery("#"+id_check+" option:selected").val();
|
||||
// now validate
|
||||
if (tmp >= 1) {
|
||||
total++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
// simple sort function
|
||||
function fanAsgfdSffsSort(a,b) {
|
||||
return a - b;
|
||||
}
|
||||
|
||||
// simple absent function
|
||||
function fanAsgfdSffsAbsent(arr){
|
||||
var absentArray = [], min= 1, max = arr[arr.length-1];
|
||||
while(min < max){
|
||||
if(jQuery.inArray(min, arr) == -1) {
|
||||
absentArray.push(min);
|
||||
}
|
||||
min++;
|
||||
}
|
||||
return absentArray;
|
||||
}
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user