Open Model on edit in list view - laravel-backpack

In backpack list view when I click in edit button then I get redirected to another page instead of I want model window where I edit and save the record. Also want for Add New.
How can I do that?

The system really isn't designed for that behaviour to be changed, but if you REALLY need it i guess you can create new files in your resources/views/vendor/backpack/crud. This will make Backpack use those views instead of the ones in the package. You can copy views from the package and change them to fit your need:
- list.blade.php would include edit.blade.php in a bootrap modal;
- buttons/edit.blade.php should trigger the right modal on click;
- edit.blade.php should submit the form with ajax instead and catch the errors, to show them inside the modal;
The same process needs to be repeated for the create.blade.php file.
It won't be easy...

Related

Function across multiple view controllers

I am trying to make a function so that I request a 'manager override' where it presents a screen for a manager to enter their password and press an approve button. How should I do this? Will it have to be in multiple functions? Is there a way that I can call one function and it present the information back? Would a completion work for what I need? I have no ideas where to start for this.
My set up is as follows:
A view controller asks for manager approval, then a screen slides up with text boxes and an approve button. I want the approve button to trigger authenticating and dismissing the screen
Assuming you don't want a Framework target (that sounds like overkill for what you want) simply mark the function as "public" and move it outside of any class. I just tried in a sample project and it works.
It looks important - remember to keep it in a file already in the project. (My sample project didn't work with menu option File|Add|New|File.)
Now, if you really want portability, check out how to create a Framework project.

SAPUI5 - Basic info - how to manage UI elements in view.js?

experts,
These are two very basic connected questions.
I'm studying SAPUI5 and I cannot find means to position my UI elements on the screen.
In my view.js file I create, let's say, a button, a datepicker and a text field.
If I do something like:
aControls=[];
<Define the button - oButton>
aControls.push(oButton);
<Define the datepicker - oDatePicker>
aControls.push(oDatePicker);
<Define the text field - oText>
aControls.push(oText);
return aControls;
then I get all three elements positioned in a row one right after another.
I cannot use css, because I pass all those objects in one array and all of them are placed into a common div on index.html.
How do I position these? A link to any good tutorial/examples is very welcome.
Also, how do I refresh UI elements?
For example, I have situation, when on button press I make a call to the server, get response and put it into a using something like:
response.placeAt('some-id');
The button is created in the view.js and the call is processed in controller.js.
The response is added every time I press the button and I have no idea how to replace the old response with the new one.
A good link is very welcome.
Thanks.
There are a lot of layout controls of SAPUI5 you can use: Grid, HorizontalLayout, VerticalLayout, MatrixLayout,etc. You can check the examples and see how you need to layout your views.
You are currently doing UI5 JS view which implements createContent method to define views, this is one approach. Another common approach is to use XML views, it is declarative and more straightforward, also needs less code. See this simple example in JSBin of defining XML view and controller to refresh UI.
SAP UI5 is all about Model(JSONModel/ODataModel)-View(JSView/XMLView)-Controller. You are highly recommend to read this MVC example, though it is based on SAP UI5 mobile, the content is relevant to SAP UI5 desktop as well.
Hope you will get some hints.

Updating a view from a command handler

I have a file dialogue opening from the menu where a user can select a file. The FileDialog is called from the menu command's handler class in execute().
Based on the file the user selected, I would like to update a view, for which (I believe) I'd need the same Composite element that's passed to the view in createPartControl().
Is it possible to get access to it from the command handler, or would it be better to trigger the view updating via something like ISourceProviderListener or PropertyChangeListener?
Thank you.
Yes, it's possible:
IViewPart part = HandlerUtil.getActiveWorkbenchWindow(executionEvent).getActivePage()
.findView(viewId);
It would be better to first update the data that your view is displaying (the model in MVC) and the change in data should trigger view refresh. It's hard to say which listener is better without knowing all the details.

How to find in GSP from which action of controller its been called?

I am new to grails and i got stuck with another issue.
I have two form's in my single GSP search.gsp and have two actions in my controller serach and results.
Now when i click on search button in one of my GSP file it takes me to search action which renders me search.gsp.At this time it should display me only first form in it. when i click results button in that form it will take me to results action.which has code line.
redirect(action:"search",params:[merchants:merchant,address:address])
this will take me back to search action but now i want to display 2nd form in search.gsp..
My problem is
how can i make search action once to run with out parameter's and once with parameter's?
how to determine in GSP from which action its been called?
with Advance thanks.
Depending on how different your forms are, you may want to consider having two separate GSP files (e.g., search.gsp and results.gsp). Use render(view:'action', model:[...]) to render a different view in the controller. This is often clearer that a single file with lots of conditionals.
Otherwise, you can find out the action using ${params.action}, so for example:
<g:if test="${params.action == 'search'}">
Text to show if the action is search
</g:if><g:else>
Text to show if the action is results
</g:else>
I would suggest you to separate your result page as template (_search.gsp), and render it from your result action. So that's how you will have different forms in different files.
By the way template is nothing but an ajax response, google it for detail about template in grails.

Zend Form multiselect array

I am using the Zend Framework and have setup a normal Zend Form, what I want to try to achieve is to have a button (with some javascript) that says add more and it adds another drop down menu same as the one setup in the zend form (a clone of it).
basically when the button is clicked it adds another select box like so:
<select name="type[]"> ...</select>
I can do a copy of the multi select box with a different name and insert it in the DOM and catch the post from the controller outside of the Zend form but what I was wondering if there is a proper way to achieve this and be able to validate and populate the extra fields when editing a current data stored in db if there are any extra.. Any help is appreciated, thanks.
Well remember that in your controller if you have something like:
$this->form = new Form_Someform();
You can always do:
$this->form->addElement(etc...)
Right before using isValid() or populate.
So in your controller when someone submits the form, when creating your form object you could check if any select were created dynamicaly and then create corresponding Zend_Elements and just validate against that.
Also when you reload that form you just create elements depending on whats in your database.
You could also use the forms constructor to pass in an array of selectboxes and create then right there too. Thats what I do.
The important things to remember is that you have control on the constructor and on the form object between its creation and the use of the populate() and isValid() functions.
Hope this helps.