Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Issue #2208 Adding CookieInfo Changes previously added LocalizedProperty values #2209

Open
wants to merge 3 commits into
base: 4.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,8 @@ public ActionResult CookieInfoList(GridCommand command)
Name = x.Name,
Description = x.Description,
IsPluginInfo = systemCookies.Contains(x.Name),
CookieTypeName = x.CookieType.ToString()
CookieTypeName = x.CookieType.ToString(),
id = x.Id
};
})
.ToList(),
Expand All @@ -1074,13 +1075,13 @@ public ActionResult CookieInfoList(GridCommand command)
}

[GridAction(EnableCustomBinding = true)]
public ActionResult CookieInfoDelete(string name, GridCommand command)
public ActionResult CookieInfoDelete(int Id, GridCommand command)
{
// First deserialize setting.
var privacySettings = Services.Settings.LoadSetting<PrivacySettings>();

var ciList = JsonConvert.DeserializeObject<List<CookieInfo>>(privacySettings.CookieInfos);
ciList.Remove(x => x.Name.IsCaseInsensitiveEqual(name));
ciList.Remove(x => x.Id == Id);

// Now serialize again.
privacySettings.CookieInfos = JsonConvert.SerializeObject(ciList, Formatting.None);
Expand All @@ -1105,6 +1106,7 @@ public ActionResult CookieInfoCreatePopup()
[AdminAuthorize]
public ActionResult CookieInfoCreatePopup(string btnId, string formId, CookieInfoModel model)
{
ModelState["id"].Errors.Clear();
if (!ModelState.IsValid)
return View(model);

Expand All @@ -1114,25 +1116,14 @@ public ActionResult CookieInfoCreatePopup(string btnId, string formId, CookieInf

if (ciList == null)
ciList = new List<CookieInfo>();

var cookieInfo = ciList
.Select(x => x)
.Where(x => x.Name.IsCaseInsensitiveEqual(model.Name))
.FirstOrDefault();

if (cookieInfo != null)
{
// Remove item if it's already there.
ciList.Remove(x => x.Name.IsCaseInsensitiveEqual(cookieInfo.Name));
}

cookieInfo = new CookieInfo
var cookieInfo = new CookieInfo
{
// TODO: Use MiniMapper
CookieType = model.CookieType,
Name = model.Name,
Description = model.Description,
SelectedStoreIds = model.SelectedStoreIds
SelectedStoreIds = model.SelectedStoreIds,
Id = (ciList.Count > 0 ? ciList.Max(x => x.Id) + 1 : 0),
};

ciList.Add(cookieInfo);
Expand All @@ -1157,13 +1148,13 @@ public ActionResult CookieInfoCreatePopup(string btnId, string formId, CookieInf
}

[AdminAuthorize]
public ActionResult CookieInfoEditPopup(string name)
public ActionResult CookieInfoEditPopup(int Id)
{
var privacySettings = Services.Settings.LoadSetting<PrivacySettings>();
var ciList = JsonConvert.DeserializeObject<List<CookieInfo>>(privacySettings.CookieInfos);
var cookieInfo = ciList
.Select(x => x)
.Where(x => x.Name.IsCaseInsensitiveEqual(name))
.Where(x => x.Id == Id)
.FirstOrDefault();

if (cookieInfo == null)
Expand All @@ -1177,7 +1168,8 @@ public ActionResult CookieInfoEditPopup(string name)
CookieType = cookieInfo.CookieType,
Name = cookieInfo.Name,
Description = cookieInfo.Description,
SelectedStoreIds = cookieInfo.SelectedStoreIds
SelectedStoreIds = cookieInfo.SelectedStoreIds,
id = cookieInfo.Id
};

AddLocales(_languageService, model.Locales, (locale, languageId) =>
Expand All @@ -1198,7 +1190,7 @@ public ActionResult CookieInfoEditPopup(string btnId, string formId, CookieInfoM
var ciList = JsonConvert.DeserializeObject<List<CookieInfo>>(privacySettings.CookieInfos);
var cookieInfo = ciList
.Select(x => x)
.Where(x => x.Name.IsCaseInsensitiveEqual(model.Name))
.Where(x => x.Id == model.id)
.FirstOrDefault();

if (cookieInfo == null)
Expand All @@ -1217,9 +1209,6 @@ public ActionResult CookieInfoEditPopup(string btnId, string formId, CookieInfoM
cookieInfo.CookieType = model.CookieType;
cookieInfo.SelectedStoreIds = model.SelectedStoreIds;

ciList.Remove(x => x.Name.IsCaseInsensitiveEqual(cookieInfo.Name));
ciList.Add(cookieInfo);

privacySettings.CookieInfos = JsonConvert.SerializeObject(ciList, Formatting.None);

Services.Settings.SaveSetting(privacySettings, x => x.CookieInfos, 0, true);
Expand Down Expand Up @@ -1360,7 +1349,7 @@ public ActionResult GeneralCommon(
#region POST mapping

// Set CountryId explicitly else it can't be resetted.
companySettings.CountryId = model.CompanyInformationSettings.CountryId ?? 0;
companySettings.CountryId = model.CompanyInformationSettings.CountryId ?? 0;

// (Un)track PDF logo id
_mediaTracker.Value.Track(pdfSettings, prevPdfLogoId, x => x.LogoPictureId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ public CookieInfoModel()
[SmartResourceDisplayName("Admin.Configuration.Settings.CustomerUser.Privacy.CookieInfo.Description")]
public string Description { get; set; }

[SmartResourceDisplayName("Admin.Configuration.Settings.CustomerUser.Privacy.CookieInfo.Id")]
public int id { get; set; }

[SmartResourceDisplayName("Admin.Configuration.Settings.CustomerUser.Privacy.CookieInfo.CookieType")]
public CookieType CookieType { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@
<div>
@(Html.Telerik().Grid<CookieInfoModel>()
.Name("cookie-infos-grid")
.DataKeys(keys => keys.Add(x => x.Name).RouteKey("Name"))
.DataKeys(keys => keys.Add(x => x.id).RouteKey("Id"))
.ClientEvents(events => events
.OnRowDataBound("onRowDataBound"))
.DataBinding(dataBinding => dataBinding
Expand Down Expand Up @@ -927,9 +927,9 @@
$('#cookie-infos-grid').on('click', '.t-grid-edit-cookie-infos', function (e) {
e.preventDefault();
var grid = $('#cookie-infos-grid').data('tGrid');
var tr = $(this).closest('tr');
var name = grid.dataItem(tr).Name;
var href = '@Url.Action("CookieInfoEditPopup", "Setting")?name=' + name + '&btnId=btnRefreshCookieInfos&formId=cookie-infos-form';
var tr = $(this).closest('tr');
var id = grid.dataItem(tr).id;
var href = '@Url.Action("CookieInfoEditPopup", "Setting")/' + id + '?btnId=btnRefreshCookieInfos&formId=cookie-infos-form';

openPopup(href, false);

Expand Down