Skip to content

Commit

Permalink
Choosing Inner time is now select2 with multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
codersaiful committed May 4, 2021
1 parent fde6f71 commit da5f4be
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 27 deletions.
9 changes: 5 additions & 4 deletions assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ ul#wpt_keyword_hide_mobile
padding: 12px 10px 8px 10px;
}
li.expanded_li .wpt_shortable_data{
padding: 20px 10px 15px 10px;
padding: 20px 15px 15px 15px;
}
.wpt_shortable_data
{
Expand Down Expand Up @@ -140,7 +140,8 @@ ul#wpt_keyword_hide_mobile li>span.handle.checkbox_handle>input
border: 1px solid transparent;
}
.wpt_shortable_data>input{
font-weight: bold;
font-weight: 500;
color: #333333;
}
.enabled:hover .wpt_shortable_data>input{
border: 1px solid #00769324;
Expand Down Expand Up @@ -533,12 +534,12 @@ span.purchase_code_active {
background: #e5e5e5;
}
.wpt_column_setting_extra {
padding: 0 10px 16px 10px;
/* padding: 0 10px 16px 10px; */
background: transparent;
width: calc(100% - 20px);
background: #ffffffd9;
margin-top: 21px;
border: 1px solid #dddddd91;
/* border: 1px solid #dddddd91; */
margin-bottom: 5px;
}
.wpt_column_setting_single_extra {
Expand Down
11 changes: 9 additions & 2 deletions assets/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@
option.detach();
$(target).append(option).change();
}
$('select#wpt_product_ids,select#product_tag_ids,select.wpt_select2').select2();
$('select#wpt_product_ids,select#product_tag_ids,select.wpt_select2').select2({
placeholder: "Select Option",
allowClear: true
});

$('select.internal_select').select2({
placeholder: "Select mulitple inner Items.",
allowClear: true
});
/**
* Product Exclude Include Feature Added Here,
* Which is normally in Pro Actually
Expand Down Expand Up @@ -92,7 +99,7 @@

});

$('select#wpt_product_ids,select#product_tag_ids,select.wpt_select2').on('select2:select', function(e){
$('select#wpt_product_ids,select#product_tag_ids,select.wpt_select2,select.internal_select').on('select2:select', function(e){
wptSelectItem(e.target, e.params.data.id);
});

Expand Down
60 changes: 39 additions & 21 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ function wpt_column_tag_for_all( $keyword, $_device_name, $column_settings ){

if( !function_exists( 'wpt_column_add_extra_items' ) ){
function wpt_column_add_extra_items( $keyword, $_device_name, $column_settings, $columns_array, $updated_columns_array, $post, $additional_data ){

unset( $columns_array[$keyword] ); //Unset this column. if in action, here $keyword - action
//unset( $columns_array['check'] );
unset( $columns_array['blank'] );
Expand All @@ -301,6 +301,7 @@ function wpt_column_add_extra_items( $keyword, $_device_name, $column_settings,
* Items actually Checked Items
*/
$items = isset( $column_settings[$keyword]['items'] ) ? $column_settings[$keyword]['items'] : array();
$items = is_array( $items ) ? $items : array();
$items = array_filter( $items );

/**
Expand All @@ -317,29 +318,46 @@ function wpt_column_add_extra_items( $keyword, $_device_name, $column_settings,
}
?>
<div class="column_add_extra_items">
<label>Select multiple inner items:</label>
<div class="checkbox_parent parent_<?php echo esc_attr( $keyword ); ?>">
<label for="<?php echo esc_attr( "column_settings{$_device_name}_{$keyword}" ); ?>">Select multiple inner items:</label>
<!-- <div class="checkbox_parent parent_<?php echo esc_attr( $keyword ); ?>">-->


<?php
$select = "";
$items_columns = $columns_array;
$items_columns = apply_filters( 'wpto_inside_item_arr', $items_columns, $keyword, $column_settings, $post );
$items_columns = apply_filters( 'wpto_inside_item_arr_' . $keyword, $items_columns, $column_settings, $post );
foreach($items_columns as $key => $key_val){
$seleced = in_array( $key,$items ) ? 'checked' : false;
$seleced_option = in_array( $key,$items ) ? 'selected' : false;
//var_dump($key, $keyword);
$unique_id = $keyword . '_' . $key . '_' . $_device_name;
// echo '<div class="each_checkbox each_checkbox_' . $key . '">';
?>




<?php
$items_columns = $columns_array;
$items_columns = apply_filters( 'wpto_inside_item_arr', $items_columns, $keyword, $column_settings, $post );
$items_columns = apply_filters( 'wpto_inside_item_arr_' . $keyword, $items_columns, $column_settings, $post );
foreach($items_columns as $key => $key_val){
$seleced = in_array( $key,$items ) ? 'checked' : false;
//var_dump($key, $keyword);
$unique_id = $keyword . '_' . $key . '_' . $_device_name;
echo '<div class="each_checkbox each_checkbox_' . $key . '">';
echo "<input "
. "id='{$unique_id}' "
. "type='checkbox' "
. "name='column_settings{$_device_name}[{$keyword}][items][]' "
. "value='{$key}' $seleced/><label for='{$unique_id}'>$key_val <small>($key)</small></label>";
echo '</div>';
}
?>
</div>
<p>All Items are move able. And Settings of item will come from main column. which can be inactive as Table Column.</p>
$select .= "<option value='{$key}' $seleced_option> $key_val - $key</option>";
// echo "<input "
// . "id='{$unique_id}' "
// . "type='checkbox' "
// . "name='column_settings{$_device_name}[{$keyword}][items][]' "
// . "value='{$key}' $seleced/><label for='{$unique_id}'>$key_val <small>($key)</small></label>";
// echo '</div>';
}
?>
<!-- </div>-->
<select
class="internal_select"
multiple="multiple"
id="<?php echo esc_attr( "column_settings{$_device_name}_{$keyword}" ); ?>"
name="<?php echo "column_settings{$_device_name}[{$keyword}][items][]"; ?>"
>
<?php echo $select; ?>
</select>

</div>
<?php
}
Expand Down

0 comments on commit da5f4be

Please sign in to comment.