|
@@ -25,8 +25,7 @@ namespace HyperCube.Pages
|
|
AccountModel _currentAccount;
|
|
AccountModel _currentAccount;
|
|
Survey _survey = new();
|
|
Survey _survey = new();
|
|
|
|
|
|
- List<KeyValuePair<int, SurveyItem>> _sortedItems = new(); /// wrap for items sorting
|
|
|
|
- List<KeyValuePair<int, SurveyItemOption>> _sortedOptions = new(); /// wrap for options sorting
|
|
|
|
|
|
+ List<KeyValuePair<int, SurveyItem>> _sortedItems = new(); /// wrap for items sorting
|
|
|
|
|
|
ModalInfo _modalInfo;
|
|
ModalInfo _modalInfo;
|
|
|
|
|
|
@@ -116,12 +115,14 @@ namespace HyperCube.Pages
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- void AddNewItem() => _survey.AddNewItem(_currentAccount.UUID);
|
|
|
|
-
|
|
|
|
- void AddNewOption(int ItemID) => _survey.SurveyItems[ItemID].AddNewOption(_currentAccount.UUID);
|
|
|
|
-
|
|
|
|
void NewSurvey() => NavigationManager.NavigateTo("surveyeditor", true);
|
|
void NewSurvey() => NavigationManager.NavigateTo("surveyeditor", true);
|
|
|
|
|
|
|
|
+ void AddNewItem()
|
|
|
|
+ {
|
|
|
|
+ _survey.AddNewItem(_currentAccount.UUID);
|
|
|
|
+ SortItems();
|
|
|
|
+ }
|
|
|
|
+
|
|
void ItemMove(int itemID, int step)
|
|
void ItemMove(int itemID, int step)
|
|
{
|
|
{
|
|
_survey.MoveItem(itemID, step);
|
|
_survey.MoveItem(itemID, step);
|
|
@@ -132,6 +133,12 @@ namespace HyperCube.Pages
|
|
{
|
|
{
|
|
_survey.DeleteItem(itemID);
|
|
_survey.DeleteItem(itemID);
|
|
SortItems();
|
|
SortItems();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void AddNewOption(int itemID)
|
|
|
|
+ {
|
|
|
|
+ _survey.SurveyItems[itemID].AddNewOption(_currentAccount.UUID);
|
|
|
|
+ SortOptions(itemID);
|
|
}
|
|
}
|
|
|
|
|
|
void OptionMove(int itemID, int optionID, int step)
|
|
void OptionMove(int itemID, int optionID, int step)
|
|
@@ -161,12 +168,9 @@ namespace HyperCube.Pages
|
|
|
|
|
|
void SortOptions(int itemID)
|
|
void SortOptions(int itemID)
|
|
{
|
|
{
|
|
- //Console.WriteLine($"SortOptions, itemID:{itemID}, SurveyItems.Count:{_survey.SurveyItems.Count}.");
|
|
|
|
- //Console.WriteLine($"SurveyItemOptions.Count:{_survey.SurveyItems[itemID].SurveyItemOptions.Count}.");
|
|
|
|
-
|
|
|
|
int optionPosition = 1;
|
|
int optionPosition = 1;
|
|
- _sortedOptions = _survey.SurveyItems[itemID].SurveyItemOptions.OrderBy(i => i.Value.Position).ToList();
|
|
|
|
- foreach (var item in _sortedOptions) { item.Value.Position = optionPosition++; }
|
|
|
|
|
|
+ _survey.SurveyItems[itemID].SurveyItemOptionsSorted = _survey.SurveyItems[itemID].SurveyItemOptions.OrderBy(i => i.Value.Position).ToList();
|
|
|
|
+ foreach (var item in _survey.SurveyItems[itemID].SurveyItemOptionsSorted) { item.Value.Position = optionPosition++; }
|
|
}
|
|
}
|
|
|
|
|
|
async Task<AccountModel> GetCurrentAcc()
|
|
async Task<AccountModel> GetCurrentAcc()
|