Allow edit/delete contact info in passport.
This commit is contained in:
parent
e4ae5bfcad
commit
49578836be
|
@ -765,15 +765,19 @@ void PanelController::editScope(int index, int documentIndex) {
|
||||||
case Scope::Type::Email: {
|
case Scope::Type::Email: {
|
||||||
const auto &parsed = _editValue->data.parsedInEdit;
|
const auto &parsed = _editValue->data.parsedInEdit;
|
||||||
const auto valueIt = parsed.fields.find("value");
|
const auto valueIt = parsed.fields.find("value");
|
||||||
|
const auto value = (valueIt == end(parsed.fields)
|
||||||
|
? QString()
|
||||||
|
: valueIt->second);
|
||||||
|
const auto existing = getDefaultContactValue(_editScope->type);
|
||||||
_panelHasUnsavedChanges = nullptr;
|
_panelHasUnsavedChanges = nullptr;
|
||||||
return object_ptr<PanelEditContact>(
|
return object_ptr<PanelEditContact>(
|
||||||
_panel.get(),
|
_panel.get(),
|
||||||
this,
|
this,
|
||||||
GetContactScheme(_editScope->type),
|
GetContactScheme(_editScope->type),
|
||||||
(valueIt == end(parsed.fields)
|
value,
|
||||||
? QString()
|
(existing.toLower().trimmed() != value.toLower().trimmed()
|
||||||
: valueIt->second),
|
? existing
|
||||||
getDefaultContactValue(_editScope->type));
|
: QString()));
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
Unexpected("Type in PanelController::editScope().");
|
Unexpected("Type in PanelController::editScope().");
|
||||||
|
|
|
@ -270,6 +270,18 @@ void PanelEditContact::setupControls(
|
||||||
st::passportFormLabel),
|
st::passportFormLabel),
|
||||||
st::passportFormLabelPadding));
|
st::passportFormLabelPadding));
|
||||||
|
|
||||||
|
if (auto text = _controller->deleteValueLabel()) {
|
||||||
|
_content->add(
|
||||||
|
object_ptr<Info::Profile::Button>(
|
||||||
|
_content,
|
||||||
|
std::move(*text) | Info::Profile::ToUpperValue(),
|
||||||
|
st::passportDeleteButton),
|
||||||
|
st::passportUploadButtonPadding
|
||||||
|
)->addClickHandler([=] {
|
||||||
|
_controller->deleteValue();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const auto submit = [=] {
|
const auto submit = [=] {
|
||||||
crl::on_main(this, [=] {
|
crl::on_main(this, [=] {
|
||||||
save();
|
save();
|
||||||
|
|
|
@ -329,13 +329,13 @@ not_null<Ui::RpWidget*> PanelEditDocument::setupContent(
|
||||||
inner->add(
|
inner->add(
|
||||||
object_ptr<Ui::FixedHeightWidget>(inner, st::passportDetailsSkip));
|
object_ptr<Ui::FixedHeightWidget>(inner, st::passportDetailsSkip));
|
||||||
if (auto text = _controller->deleteValueLabel()) {
|
if (auto text = _controller->deleteValueLabel()) {
|
||||||
_delete = inner->add(
|
inner->add(
|
||||||
object_ptr<Info::Profile::Button>(
|
object_ptr<Info::Profile::Button>(
|
||||||
inner,
|
inner,
|
||||||
std::move(*text) | Info::Profile::ToUpperValue(),
|
std::move(*text) | Info::Profile::ToUpperValue(),
|
||||||
st::passportDeleteButton),
|
st::passportDeleteButton),
|
||||||
st::passportUploadButtonPadding);
|
st::passportUploadButtonPadding
|
||||||
_delete->addClickHandler([=] {
|
)->addClickHandler([=] {
|
||||||
_controller->deleteValue();
|
_controller->deleteValue();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue