I understand how the call to the app service is made in the typical EditModal.js file (shown below). Can you tell me how I can use this same code in a totally separate JS file, that is not attached to a modal?
Also, I dont have a form tag, i just want to post the HTML table row data to my app service method. So not sure if I can use this stmt: _$tenantInformationForm.serializeFormToObject() with a table row?
var EditTenantModal = (function ($) {
app.modals.EditTenantModal = function() {
var _modalManager;
var _tenantService = abp.services.app.tenant;
var _$tenantInformationForm = null;
this.init = function (modalManager) {
_modalManager = modalManager;
_$tenantInformationForm = _modalManager.getModal().find('form[name=TenantInformationsForm]');
_$tenantInformationForm.validate();
};
this.save = function () {
if (!_$tenantInformationForm.valid()) {
return;
}
var tenant = _$tenantInformationForm.serializeFormToObject();
_modalManager.setBusy(true);
_tenantService.updateTenant(
tenant
).done(function () {
abp.notify.info(app.localize('SavedSuccessfully'));
_modalManager.close();
abp.event.trigger('app.editTenantModalSaved');
}).always(function () {
_modalManager.setBusy(false);
});
};
};
})(jQuery);
I would like to have each page/module in my application be able to set the modal size used by the modal manager. Currently as a temporary solution I have modified the Modal manager code to use modal-full. I need this for some of my modules where there is quite a large form with lots of data being collected. There are other modules where the form is smaller and does not require the larger modal. So I would like to be able to change this dynamically.
How can I pass the modal class as a parameter to the modal manager? The line shown in red box below is what I am looking to modify/pass in as parameter. [attachment=0:o5dbo9ht]Screenshot (54).png[/attachment:o5dbo9ht]
Ok I will check that out and see if I can implement it.
I have been working on alternate solution to this problem. I have implemented a DataTables GRID in my edit modal to hold all the addresses for the company entity. This datatable is fully editable and new rows can be added. The data tables provides a facility to make AJAX call to server side methods.
Can you tell me if I should implement a pure AJAX call to a new method in my controller for this update from the datatables grid OR should i use the ABP app service code method, where the form content is serialized and then posted to the AppService method? Is that possible?
Thanks very much for your help with Note issue!
I still have this issue with the sub-entity updates. Can you provide a suggestion on the issue described above?
Thanks for the reply!
It turns out that the Bootstrap_DatePicker and Bootstrap_DateTimePicker were not in the "libs" folder.
I added those folders and updated the script paths file and it finally worked!
I added it as shown below. It did not work, until I placed the code at the end of my script.
(function ($) {
app.modals.CreateNurseHomeModal = function () {
//Did not work here
//$('.datepicker').datepicker();
var _nurseHomeService = abp.services.app.nurseHome;
var _$form = null;
var _modalManager;
this.init = function (modalManager) {
_modalManager = modalManager;
//Did not work here
//$('.datepicker').datepicker();
_$form = _modalManager.getModal().find('form[name=CreateHome]');
_$form.validate();
};
this.save = function () {
if (!_$form.valid()) {
return;
}
var home = _$form.serializeFormToObject();
_modalManager.setBusy(true);
_nurseHomeService.createNurseHome(
home
).done(function () {
abp.notify.info(app.localize('SavedSuccessfully'));
_modalManager.close();
abp.event.trigger('app.createNurseHomeModalSaved');
location.reload();
}).always(function () {
_modalManager.setBusy(false);
});
};
};
//Works here, but shows JQuery datepicker
$('.datepicker').datepicker();
})(jQuery);
However the above code renders the JQuery calendar? [https://drive.google.com/open?id=0B5HAoiVVXzY7WG01cnk4bGZlMEE])
I am having this exact same issue on my Create Modal. I cannot get any of the date picker to display. Even the default date range picker is not rendering.
Here is a screenshot of the Google chrome console showing that all the scripts are present on the page, yet the calendar is not displayed? [https://drive.google.com/open?id=0B5HAoiVVXzY7d1liWTFmZG9kblk])
I am working on the MPA JQuery MVC solution.
Related to this same issue, I am also running into the same issue as posted here: [http://forum.aspnetboilerplate.com/viewtopic.php?p=6142#p6142])
When the "UpdateCompany" app service method is called, the address and contacts are posted back as empty.
Is that something that cannot be achieved with ABP template and EF?
I have a need to do this with multiple entities in my project.
For example, Company entity. When the user edits a company, they should be able to update the company, addresses and contacts for the company, all from the single edit modal. When they click save any changes to company, address or contacts needs to be saved into DB.
Hi @ISMCAGDAS
I emailed you my solution and sent you an email about this issue about 2 weeks ago. I also sent you another email a few days ago. I am still having this issue with entity update method in my app service.
Here is debug showing complete "cmp" object. [https://drive.google.com/open?id=0B5HAoiVVXzY7WVdBM2g0X3pTMkE])
Here are the note entity DTOs. [https://drive.google.com/open?id=0B5HAoiVVXzY7dmFwbUZocDJYd0U])
The log file shows the below error.
ERROR 2017-02-19 12:40:41,634 [10 ] 17.EntityFramework.NursingOps17DbContext - - Note: The Note field is required.
ERROR 2017-02-19 12:40:41,634 [10 ] 17.EntityFramework.NursingOps17DbContext - - Note: The Note field is required.
ERROR 2017-02-19 12:40:41,705 [10 ] nHandling.AbpApiExceptionFilterAttribute - Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.
I have checked all my DTO's and I do not see "required" annotation on any property named "Note".
Can you please help? Thanks!
I copied that code from the ABP code in the editions app service, see below. I am using this exact same code for another entity and it works just fine there too.
//Edition app service method
//var editionItems = new ListResultDto<ComboboxItemDto>(editions.Select(e => new ComboboxItemDto(e.Id.ToString(), e.DisplayName)).ToList()).Items.ToList();
//country app service method
var countryItems = new ListResultDto<ComboboxItemDto>(countries.Select(e => new ComboboxItemDto(e.Id.ToString(), e.CountryName)).ToList()).Items.ToList();
Why does it not work here?
public async Task<List<ComboboxItemDto>> GetEditionComboboxItems(int? selectedEditionId = null)
{
var editions = await _editionManager.Editions.ToListAsync();
var editionItems = new ListResultDto<ComboboxItemDto>(editions.Select(e => new ComboboxItemDto(e.Id.ToString(), e.DisplayName)).ToList()).Items.ToList();
var defaultItem = new ComboboxItemDto("null", L("NotAssigned"));
editionItems.Insert(0, defaultItem);
Also, I could not get your suggested code to work either. It gives syntax error soon as the statement is coded.