Commit 5a197d5c authored by Nicolas Jager's avatar Nicolas Jager

smartpanel : delete ring account from the panel

Change-Id: Ie40094e31cfb975ea7f518f068b6c38eb5504e6b
Tuleap: #1246
parent d8e49595
......@@ -37,6 +37,7 @@ public:
property bool _isSelected {
void set(bool value) {
isSelected_ = value;
if (!_disconnected)
NotifyPropertyChanged("_isSelected");
}
bool get() {
......@@ -44,13 +45,13 @@ public:
}
}
property bool _editionMode;
property bool _disconnected;
protected:
void NotifyPropertyChanged(String^ propertyName);
private:
bool isSelected_;
};
}
}
......
......@@ -60,3 +60,14 @@ RingClientUWP::ViewModel::AccountListItemsViewModel::findItem(String^ accountId)
return nullptr;
}
void RingClientUWP::ViewModel::AccountListItemsViewModel::removeItem(AccountListItem ^ item)
{
unsigned int index;
itemsList_->IndexOf(item, &index);
item->_disconnected = true; // avoid disconected exception.
itemsList_->RemoveAt(index);
}
......@@ -43,6 +43,7 @@ internal:
/* functions */
AccountListItem^ findItem(String^ accountId);
void removeItem(AccountListItem^ item);
/* properties */
property Vector<AccountListItem^>^ itemsList
......
......@@ -727,6 +727,8 @@ void RingClientUWP::Views::SmartPanel::_editAccountMenuButton__Click(Platform::O
auto account = AccountListItemsViewModel::instance->_selectedItem->_account;
_aliasTextBoxEditionMenu_->Text = account->name_;
_accountEditionMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_deleteAccountBtnEditionMenu_->IsChecked = false;
_deleteAccountBtnEditionMenu_->IsEnabled = (AccountListItemsViewModel::instance->itemsList->Size > 1)? true : false;
}
......@@ -739,19 +741,19 @@ void RingClientUWP::Views::SmartPanel::_acceptAccountModification__Click(Platfor
// mettre ca en visibility du bouton delete
auto accountsListSize = dynamic_cast<Vector<AccountListItem^>^>(_accountsList_->ItemsSource)->Size;
/* if the delete button is toggled, just delete the account */
if (_deleteAccountBtnEditionMenu_->IsChecked && accountsListSize > 1) {
RingD::instance->deleteAccount(accountId);
AccountListItem^ item;
for each (item in AccountListItemsViewModel::instance->itemsList)
if (item->_account->accountID_ == accountId)
break;
/* rebuild a new list of accounts without the one to delete */
auto newAccountList = ref new Vector<AccountListItem^>();
for each (AccountListItem^ item in AccountListItemsViewModel::instance->itemsList) {
if (item->_account->accountID_ != accountId)
newAccountList->Append(item);
}
if (item)
AccountListItemsViewModel::instance->removeItem(item);
_accountsList_->ItemsSource = newAccountList;
RingD::instance->deleteAccount(accountId);
} else {
} else { /* otherwise edit the account */
account->name_ = _aliasTextBoxEditionMenu_->Text;
account->_upnpState = _upnpState_->IsOn;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment