Is it possible to remove the 'Delete' and 'Add x' on the 'table' field for Laravel Backpack? - laravel-backpack

I'm currently setting up a backpack CRUD for languages/translations, and I'd like the translations to be bulk editable from the language CRUD. I've currently got that working through the update operation like so:
protected function setupUpdateOperation()
{
$this->setupCreateOperation();
CRUD::addField([
'name' => 'translations',
'label' => 'Translations',
'type' => 'table',
'entity_singular' => 'translation',
'columns' => [
'key' => 'Key',
'text' => 'Text'
]
]);
}
Which looks like this:
preview image
The problem I'm running into here is that all the 'keys' should be static (but still displayed), as well as that users shouldn't be able to 'add' translations or remove them. (Translation creation is handled by setting up default translations each time a language is created)
Is it possible to
Make it so that the 'key' column is uneditable but still displayed.
Remove the 'Add translation' button at the bottom of the table.
Remove the 'Delete' trashcan icon at the end of each translation line
Many thanks in advance!

Add these lines to your Controller. You can add it anywhere but I prefer to add in public function setup()
$this->crud->denyAccess('delete');
$this->crud->denyAccess('create');
However user cannot add Translation but this will not remove the + Add Translation button. So to remove that button also,
remove this line
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
Sources:
https://github.com/Laravel-Backpack/CRUD/issues/257
https://backpackforlaravel.com/docs/4.1/crud-operation-show

Related

How do I show a field based on the selection of another field

I have a form field, when I select a car, I want to get the type of car or the result of the model.
$this->crud->addField([
'name' => 'car_id',
'label' => 'Car',
'type' => 'select2_from_ajax',
'attribute' => 'name',
'model' => Car::class,
'data_source' => url('admin/api/cars'),
'placeholder' => 'Search and select a car',
'minimum_input_length' => 2,
]);
And how do I use the result to determine which other fields to show in the form?
You can do that in Backpack v5 using the included CrudField JS Library. To hide/show other fields depending on card_id, you should:
Step 1. In your setupCreateOperation() and/or setupUpdateOperation() load a new JS file:
Widget::add()->type('script')->content('assets/js/admin/forms/product.js');
Step 2. Create that JS file. Inside it, you can now easily select and get the value of Backpack fields. To show/hide other fields depending on car_id:
crud.field('car_id').onChange(function(field) {
// eg. show "car_model" if "car_id" is 1
crud.field('car_model').show(field.value == 1);
}).change();
For more things you can do with the CrudField JS Library, check out its docs.

How to add custom action button in suiteCRM module sub panel list?

I need some suggestion in my suite CRM module integration.
I have a sub-panel in one of my modules and required to add one more edit button to redirect to a custom form to take some input from the user for each row separately.
Below is a sample image of my sub-panel list view.
In the above image on click of the edit button of a row, there is a remove button, I want to add one more custom button after remove and need to redirect from there to my new form.
I have checked some of forums and blogs but didn't found the solution.
To add a button you will need to modify the metadata of that sub-panel. In metadata, you will see the following code for the Edit and Remove buttons:
'edit_button' =>
array (
'vname' => 'LBL_EDIT_BUTTON',
'widget_class' => 'SubPanelEditButton',
'module' => 'Contacts',
'width' => '5%',
'default' => true,
),
'remove_button' =>
array (
'vname' => 'LBL_REMOVE',
'widget_class' => 'SubPanelRemoveButton',
'module' => 'Contacts',
'width' => '5%',
'default' => true,
),
You can add your new button using same array syntax. As you can see that every button use specific widget class(defined as widget_class) therefore you will need to add new widget_class class for that. You can find existing widget classes in this folder: include/generic/SugarWidgets.
Cheers!

How to unmerge edit and remove buttons in sugarCRM?

When in SugarCRM CE when I insert an edit button into a custom sub panel meta file for some reason it merges it with the "remove" button as per attach. So the edit button gets a dropdown arrow and 'remove' button appears when we click on the arrow.
The code I use to show the buttons is
// Edit button
'edit_button'=>array(
'widget_class' => 'SubPanelEditUsersprjct_projectsButton',
'projects_users_id'=>'projects_users_id',
'module' => 'Users',
'width' => '5%',
),
'remove_button'=>array(
'vname' => 'LBL_REMOVE',
'widget_class' => 'SubPanelRemoveButton',
'module' => 'Users',
'width' => '4%',
'linked_field' => 'users',
),
How do I get the 2 buttons to show up next to each other.
Exact same issue as described here: http://wiki-crm-forum.com/forum/viewtopic.php?f=2&t=9632&p=33429&sid=e82d1abbf9f4d0b39f01137dd9e4c913#p33429 but there's no solution it seems
I see the problem but I have a workaround.
You may remove "Remove" from subpanels and use this free plugin to add "Remove" button in subpanel in front of each row.
https://store.outrightcrm.com/product/outright-listview-delete/

How to change the default order of the sub panels in the opportunities module

I have a need to change the default order of the sub panels in the opportunities module. I have been looking for a solution for a while and have not found a solution that works.
I am using SugarCRM CE 6.5.13
Thanks in advance.
Your question is actually unclear. Are you asking for the order of a subpanel meaning how to place one subpanel above another. Or is your question concerning the order of the data inside a subpanel?
A fast response to both is:
in {MainModule}/metadata/subpaneldefs.php there should be the sort order declared for the subpanel like this:
$layout_defs[{MainModule}] = array(
// list of what Subpanels to show in the DetailView
'subpanel_setup' => array(
'{TheSubpanel}' => array(
'order' => 1, // influences the place of the subpanel relative to the other subpanels
'module' => '{TheSubpanel}',
'subpanel_name' => 'default', // attention please check the subpanel module to make sure there is not another setting overriding this setting
'sort_order' => 'desc',
'sort_by' => 'date_entered',
...
check also the file defined above that contains the subpanels fields. In this case it can be found in {TheSubpanel}/metadata/subpanels/default.php
$module_name = '{TheSubpanel}';
$subpanel_layout = array(
'top_buttons' => array(
'where' => '',
'sort_order' => 'desc',
'sort_by' => 'date_entered',
Please consider that after a change you need to run 'rebuild & repair' and if you manually clicked on a sort field then you should clear your cookie cache and log in again too.
There are other questions on stack overflow concering this like how-to-change-default-sort-in-custom-subpanel-sugarcrm
If you do not want code level customization then you can just drag and drop the sequence of subpanels on detail view of record. The sequence of subpanel will be saved.

"Theme Customizer" - different background image for different category

I'm trying to make setting in theme customizer which will allow me to choose different background image to different category. I have two settings working separately, but i don't know how to combine them to work together and it seems like there was no problem like this before.
In theme customizer it looks like
> this <.
How make it work together?
EDIT:
I was trying in many ways to acomplish this, but only thing that worked as i wanted was creating a section for each category and add background image there, like this:
$wp_customize->add_section( 'background_section_cat_a', array(
'title' => __( 'Category: cat_a', 'twentythirteen-child'),
'description' => 'Options prepared to change background settings', 'twentythirteen-child',
'priority' => 160,
'panel' => 'background_panel',
));
$wp_customize->add_setting( 'background_image_cat_a', array(
'default' => 'abc.jpg',
));
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'background_image_cat_a', array(
'label' => __( 'Select background image', 'twentythirteen-child' ),
'section' => 'background_section_cat_a',
'settings' => 'background_image_cat_a',
)));
and use this setting:
body.category-cat-a {
background-image: url(<?php echo get_theme_mod('background_image_cat_a'); ?>);}
But when I add new category, I have to enter my theme customizer options and add it there, and it is very time time consuming.
There is another way:
1. Add custom field with image to your Category taxonomy
2. call your image in category.php page.