I use backpack and laravel and I want to see deleted item in show for example...
but because soft delete active a global scope I can't see the deleted item.
I don't know how to deactive scope in some operation for example in show operation that backpack use it for showing an element...
I hope you help me...
I'm using backpack-revision and when I want to see the revisions for a soft deleted item I have that problem too.
To show them inside the list operation I usually add a filter like this in my setupListOperation():
$this->crud->addFilter(
[
'type' => 'simple',
'name' => 'trashed',
'label'=> 'Trashed',
],
false,
function ($values) {
// if the filter is active
$this->crud->query = $this->crud->query->onlyTrashed();
}
);
To show them in other operations it should be possible to something like:
public function setupShowOperation()
{
$this->crud->query = $this->crud->query->withTrashed();
}
In Backpack 5, this was the solution for me:
protected function setupShowOperation()
{
$this->setupListOperation();
$this->crud->set('show.softDeletes', true);
}
This is an undocumented feature, but I found this in the show() method of the ShowOperation trait.
Related
I need to add and operation to handle downloading of a file.
How can i create route, and add setupDownloadOperation in the right way?
Or must I simply do 'laravel-way' manually adding a route?
Actually we did this
First - Create a setupDownloadRoutes
Actually this is called automatically ad boot
protected function setupDownloadRoutes($segment, $routeName, $controller)
{
Route::get($segment. '/{id}/download', [
'as' => $routeName . '.download',
'uses' => $controller . '#download',
'operation' => 'download',
]);
}
Create the setupDownloadOperation function
It's automatically launched if found. If you have nothing to do here you can avoid to create it.
protected function setupDownloadOperation()
{
...do things here...
}
Create the download function.
This is the classic controller action of Laravel
protected function download()
{
... do thing as usually in a normal action ...
}
I do not find these procedure documented actually
The docs here cover exactly what you need. Just replace “moderate” with “download” in the naming - https://backpackforlaravel.com/docs/4.1/crud-operations
I am using dynamic data with reactiveui,
` _propList.Connect()
.WhenAnyPropertyChanged()
.Subscribe(t =>
{
}`
the code will be trigger if I just edit any item in the grid. However, when I try to add or remove an item, it is not triggered.
In my view model I have something like this
private SourceList<Decision> _myList { get; set; } = new SourceList<Decision>();
private readonly IObservableCollection<Decision> _targetCollection = new ObservableCollectionExtended<Decision>();
public IObservableCollection<Decision> TargetCollection => _targetCollection;
in my view, I simply
this.OneWayBind(VM, vm => vm.TargetCollection, v => v.DataGrid1.DataSource);
If I remove or Add item in the grid, and press Save
_myList.Count() didn't change, but
_TargetCollection.Count() will increase or decrease by number of items I delete
In my ViewModel
OKCmd = ReactiveCommand.Create(() =>
{
//// _myList.Connect()
////.Subscribe(t =>
//// {
//// ;
//// }
//// );
t.Items.count() and it is the initial load items, but I couldn't seem to know what items have been added or removed. Am I missing something.
Of course, I can keep track of what items are added or removed in the UI, but I am hoping I don't have to do that.
Thanks.
To help me answer your question, I need to better understand what you are trying to achieve but first I will explain what the default behaviour of DD is.
If you want add / remove events you need _propList.Connect().Subscribe(changes => ...). These are the collection changes and you will receive all collection change events including the initial load, but no inline changes.
By default, no property changes are wire in. This is because to monitor property changes is expensive and is opt in only. Also WhenAnyPropertyChanged() never tiggers for the initial load. This is because the item is already loaded and no properties have changed between Connect being called and the property changed observable being subscribed to.
Following on from 2, you will never receive a property changed when an item is removed from the underlying source. This is because when an item it removed, any inline subscriptions are disposed of. Otherwise there would be memory leaks.
Another option for monitoring inline changes is to make use of 'MergeMany' which allows you to craft any observable on a specific item, and in your case you can create an observable to return the initial value as well as as subsequent changes.
It is possible using standard rx to listen to collection changes and inline changes in a single observable, which you would have to compose yourself. For example
var myCollectionChanges = _propList.Connect();
var myPropertyChanges = _propList.Connect().WhenAnyPropertyChanged();
var allMyChanges = myCollectionChanges.Select(_ => Unit.Default)
.Merge(myPropertyChanges.Select(_ => Unit.Default));
In the this example, I have used Select(_ => Unit.Default) to enable the merge operator as it requires the same signature. However what signature is returned is up to you, the key point being that the signatures must match.
I wanted to know if there's a way to customize the select option from the subpanel men in Suitecrm.
All one-to-many relationships for a module's subpanel are to be removed whereas for many to many need to rename it to "Associate Module 1 to Module 2 ".
Can I achieve this and this is to be done for all modules.
To remove buttons:
Assume that Target module and Lead module has one to many Relationshipship. Now Leads will be shown under the Traget Record Detailview. So if we want to remove selection and creation of Lead from Subpanel of Lead. Then we can hide this two buttons from following code:
Find The relation ship file in
custom/Extension/modules/Prospects/Ext/Layoutdefs/prospects_leads_1_Prospects.php
Remove Commented code as commented in this relationship code as Below,
And then Repair and Rebuild.
$layout_defs[“Prospects”][“subpanel_setup”][‘prospects_leads_1’] = array (
‘order’ => 100,
‘module’ => ‘Leads’,
‘subpanel_name’ => ‘default’,
‘sort_order’ => ‘asc’,
‘sort_by’ => ‘id’,
‘title_key’ => ‘LBL_PROSPECTS_LEADS_1_FROM_LEADS_TITLE’,
‘get_subpanel_data’ => ‘prospects_leads_1’,
‘top_buttons’ =>
array (
/*
0 =>
array (
‘widget_class’ => ‘SubPanelTopButtonQuickCreate’,
),
1 =>
array (
‘widget_class’ => ‘SubPanelTopSelectButton’,
‘mode’ => ‘MultiSelect’,
),
*/
),
);
moreover, you can check labelvalue and then change label in language file accordingly.
To Rename button at system level:
Place following language label in custom/include/language/en_us.lang.php
$GLOBALS['app_strings']['LBL_SELECT_BUTTON_LABEL'] = 'your label';
This will change the label for all but if you want to change it via some logic then see file: include\generic\SugarWidgets\SugarWidgetSubPanelTopSelectButton.php, it has public function getDisplayName() where you can add some logic to change that label in a specific condition. Hopefully, you will write that logic your own. Also, you can return empty html in those cases where you don't need button.
Basically: Every time I add a new class/model with the extension_builder and then want to create a record of that class I get the following error message:
2: SQL error: 'Unknown column 'edited' in 'field list''
(tx_icingaconfgen_domain_model_checkperiod:NEW5a27f9da8a41d636846075)
The interesting thing is: "edited" is NOT a property of that class, but the property of other classes in that extension. I've searched through the TCA of the class that throws the error and also the MySql table itself, but the field "edited" is indeed not part of that class. What's going on here?
Edit: What I find interesting is the fact that when I add a column "edited" to MySql table manually, the record can be created. But in no way I'm using this property in my Model. Why does it require a MySql column of that name then?
Without seeing the code I can only guess whats going on. Surely the field is requiered when a record is persisted. So it is possible that you referenced it in your TCA. If not in the columns maybe in the ctrl section:
'ctrl' => [
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
...
],
These fields are updated automatically if a recods is changed or created. There are more of those fields. So check your ctrl section.
It is also possible that you map another property (possibly even of another class) to that database field in your TypoScript like this:
plugin.tx_myextension {
persistence {
classes {
MyVendor\MyExtension\Domain\Model\Person {
mapping {
tableName = tt_address
recordType = \MyVendor\MyExtension\Domain\Model\Person
columns {
birthday.mapOnProperty = dateOfBirth
}
}
}
}
}
}
Example taken from here.
As it turned out the culprit was actually this line of code in the ext_localconf.php:
$GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']['extkey'] = 'Cjk\\Icingaconfgen\\Hook\\EvalHook';
$GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass']['extkey'] = 'Cjk\\Icingaconfgen\\Hook\\EvalHook';
It's a hook that I've implemented into my extension that just marks if a record has been edited in the BE or not. I actually use this Hook that whenever a record is edited changes the propety edited from 0 to 1. This is intended of course, but the class checkperiod doesn't have the property 'edited'. But since the hook for the Datamapper works with every record that is changed or created it also tries to change 'edited' in classes that don't have this property. A simple if condition in the Hook itself, if the key 'edited' of the $fieldArray is NULL solved my problem.
class EvalHook {
function processDatamap_postProcessFieldArray($status, $table, $id, &$fieldArray, &$pObj) {
if($status == "update" && $table != 'tx_icingaconfgen_domain_model_checkperiod'){
$fieldArray[edited] = 1;
}
elseif($status != "update" && $table != 'tx_icingaconfgen_domain_model_checkperiod){
$fieldArray[edited] = 0;
}
}
}
I have a form that triggers on event in __construct method to load some items from another modules . So far so good , a field set is loaded from the other module and added to the form and in the request->getPost() I have the data for the elements inside the fieldset , but the $form->getData() doesn't have the data for the fieldset.
I am calling $form->getInputFilter() before adding this fieldsets to the form and it seems that calling the $form->getInputFilter() dosn't creates the filters for the newly added elements . so how can i create inputfilters for the dynamic events without recreating the hole filters again ?
Or should i just delay calling $form->getInputFilter() untill all of the elemnts have been added to the form ?
I also added some elements to the form later what was ignored by the input filter.
My solution is most likely not exactly the best one, but as you haven't received any other answers yet, here's what I did:
I added
use Zend\InputFilter\Factory as InputFactory;
in the class where I'm validating the form data and then used
$factory = new InputFactory();
$form->getInputFilter()->add($factory->createInput(array(
'name' => 'title_str',
'required' => true,
'filters' => array(
array('name' => 'Int'),
),
)));
#Afterdark017 that works and also i think it is possible to reset the filters.
protected function resetFilters(){
$this->filter = null;
$this->hasAddedInputFilterDefaults = false;
}
but i have not tested this yet.