mirror of https://github.com/procxx/kepka.git
Use most-filled document from OneOf list.
This commit is contained in:
parent
e25ecce887
commit
82a3cd9bdb
|
@ -1563,7 +1563,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_passport_identity_internal" = "Internal passport";
|
"lng_passport_identity_internal" = "Internal passport";
|
||||||
"lng_passport_identity_internal_upload" = "Upload a scan of your internal passport";
|
"lng_passport_identity_internal_upload" = "Upload a scan of your internal passport";
|
||||||
"lng_passport_identity_about" = "The document must contain your photograph, first and last name, date of birth, document number, country of issue, and expiry date.";
|
"lng_passport_identity_about" = "The document must contain your photograph, first and last name, date of birth, document number, country of issue, and expiry date.";
|
||||||
"lng_passport_identity_selfie" = "Take a selfie with your document";
|
|
||||||
"lng_passport_address_title" = "Residential address";
|
"lng_passport_address_title" = "Residential address";
|
||||||
"lng_passport_address_description" = "Upload a proof of your address";
|
"lng_passport_address_description" = "Upload a proof of your address";
|
||||||
"lng_passport_address_bill" = "Utility bill";
|
"lng_passport_address_bill" = "Utility bill";
|
||||||
|
@ -1584,6 +1583,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_passport_phone_description" = "Enter your phone number";
|
"lng_passport_phone_description" = "Enter your phone number";
|
||||||
"lng_passport_email_title" = "Email";
|
"lng_passport_email_title" = "Email";
|
||||||
"lng_passport_email_description" = "Enter your email address";
|
"lng_passport_email_description" = "Enter your email address";
|
||||||
|
"lng_passport_identity_selfie" = "Take a selfie with your document";
|
||||||
|
"lng_passport_translation_needed" = "Upload a translation of your document";
|
||||||
"lng_passport_accept_allow" = "You accept the {policy} and allow their {bot} to send you messages.";
|
"lng_passport_accept_allow" = "You accept the {policy} and allow their {bot} to send you messages.";
|
||||||
"lng_passport_allow" = "You allow {bot} to send you messages.";
|
"lng_passport_allow" = "You allow {bot} to send you messages.";
|
||||||
"lng_passport_policy" = "{bot} privacy policy";
|
"lng_passport_policy" = "{bot} privacy policy";
|
||||||
|
@ -1596,27 +1597,23 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_passport_upload_scans" = "Upload scans";
|
"lng_passport_upload_scans" = "Upload scans";
|
||||||
"lng_passport_upload_more" = "Upload additional scans";
|
"lng_passport_upload_more" = "Upload additional scans";
|
||||||
"lng_passport_selfie_title" = "Selfie";
|
"lng_passport_selfie_title" = "Selfie";
|
||||||
"lng_passport_selfie_name" = "Photo";
|
|
||||||
"lng_passport_selfie_description" = "Upload a photo of yourself holding your document. Make sure the ID and your face are clearly visible.";
|
"lng_passport_selfie_description" = "Upload a photo of yourself holding your document. Make sure the ID and your face are clearly visible.";
|
||||||
"lng_passport_upload_selfie" = "Upload selfie";
|
"lng_passport_upload_selfie" = "Upload selfie";
|
||||||
"lng_passport_reupload_selfie" = "Reupload selfie";
|
"lng_passport_reupload_selfie" = "Reupload selfie";
|
||||||
"lng_passport_front_side_title" = "Front side";
|
"lng_passport_front_side_title" = "Front side";
|
||||||
"lng_passport_front_side_name" = "Scan";
|
|
||||||
"lng_passport_front_side_description" = "Upload the front side of your document.";
|
"lng_passport_front_side_description" = "Upload the front side of your document.";
|
||||||
"lng_passport_upload_front_side" = "Upload a scan of the front side";
|
"lng_passport_upload_front_side" = "Upload a scan of the front side";
|
||||||
"lng_passport_reupload_front_side" = "Reupload a scan of the front side";
|
"lng_passport_reupload_front_side" = "Reupload a scan of the front side";
|
||||||
"lng_passport_reverse_side_title" = "Reverse side";
|
"lng_passport_reverse_side_title" = "Reverse side";
|
||||||
"lng_passport_reverse_side_name" = "Scan";
|
|
||||||
"lng_passport_reverse_side_description" = "Upload the reverse side of your document.";
|
"lng_passport_reverse_side_description" = "Upload the reverse side of your document.";
|
||||||
"lng_passport_upload_reverse_side" = "Upload a scan of the reverse side";
|
"lng_passport_upload_reverse_side" = "Upload a scan of the reverse side";
|
||||||
"lng_passport_reupload_reverse_side" = "Reupload a scan of the reverse side";
|
"lng_passport_reupload_reverse_side" = "Reupload a scan of the reverse side";
|
||||||
"lng_passport_main_page_title" = "Main page";
|
"lng_passport_main_page_title" = "Main page";
|
||||||
"lng_passport_main_page_name" = "Scan";
|
|
||||||
"lng_passport_main_page_description" = "Upload the main page of your document.";
|
"lng_passport_main_page_description" = "Upload the main page of your document.";
|
||||||
"lng_passport_upload_main_page" = "Upload a scan of the main page";
|
"lng_passport_upload_main_page" = "Upload a scan of the main page";
|
||||||
"lng_passport_reupload_main_page" = "Reupload a scan of the main page";
|
"lng_passport_reupload_main_page" = "Reupload a scan of the main page";
|
||||||
"lng_passport_personal_details" = "Personal details";
|
"lng_passport_personal_details" = "Personal details";
|
||||||
"lng_passport_personal_details_enter" = "Enter your personal details";
|
"lng_passport_personal_details_enter" = "Fill in your personal details";
|
||||||
"lng_passport_document_details" = "Document details";
|
"lng_passport_document_details" = "Document details";
|
||||||
"lng_passport_choose_image" = "Choose scan image";
|
"lng_passport_choose_image" = "Choose scan image";
|
||||||
"lng_passport_delete_scan_undo" = "Undo";
|
"lng_passport_delete_scan_undo" = "Undo";
|
||||||
|
@ -1636,7 +1633,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_passport_native_name_title" = "Name in document language";
|
"lng_passport_native_name_title" = "Name in document language";
|
||||||
"lng_passport_native_name_about" = "Your name in the language of the country ({country}) that issued the document.";
|
"lng_passport_native_name_about" = "Your name in the language of the country ({country}) that issued the document.";
|
||||||
"lng_passport_address" = "Address";
|
"lng_passport_address" = "Address";
|
||||||
"lng_passport_address_enter" = "Enter your address";
|
"lng_passport_address_enter" = "Please provide your address";
|
||||||
"lng_passport_street" = "Street";
|
"lng_passport_street" = "Street";
|
||||||
"lng_passport_city" = "City";
|
"lng_passport_city" = "City";
|
||||||
"lng_passport_state" = "State";
|
"lng_passport_state" = "State";
|
||||||
|
|
|
@ -386,23 +386,28 @@ void Value::fillDataFrom(Value &&other) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Value::scansAreFilled() const {
|
bool Value::scansAreFilled() const {
|
||||||
if (requiresScan(FileType::Translation) && _translations.empty()) {
|
return (whatNotFilled() == 0);
|
||||||
return false;
|
}
|
||||||
} else if (requiresScan(FileType::Scan) && _scans.empty()) {
|
|
||||||
return false;
|
int Value::whatNotFilled() const {
|
||||||
}
|
const auto noRequiredSpecialScan = [&](FileType type) {
|
||||||
const auto types = {
|
return requiresSpecialScan(type)
|
||||||
FileType::FrontSide,
|
&& (specialScans.find(type) == end(specialScans));
|
||||||
FileType::ReverseSide,
|
|
||||||
FileType::Selfie
|
|
||||||
};
|
};
|
||||||
for (const auto type : types) {
|
if (requiresScan(FileType::Scan) && _scans.empty()) {
|
||||||
if (requiresSpecialScan(type)
|
return kNothingFilled;
|
||||||
&& (specialScans.find(type) == end(specialScans))) {
|
} else if (noRequiredSpecialScan(FileType::FrontSide)) {
|
||||||
return false;
|
return kNothingFilled;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
auto result = 0;
|
||||||
|
if (requiresScan(FileType::Translation) && _translations.empty()) {
|
||||||
|
result |= kNoTranslationFilled;
|
||||||
|
}
|
||||||
|
if (noRequiredSpecialScan(FileType::ReverseSide)
|
||||||
|
|| noRequiredSpecialScan(FileType::Selfie)) {
|
||||||
|
result |= kNoSelfieFilled;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Value::saveInEdit() {
|
void Value::saveInEdit() {
|
||||||
|
|
|
@ -186,6 +186,11 @@ struct Value {
|
||||||
bool uploadingScan() const;
|
bool uploadingScan() const;
|
||||||
bool saving() const;
|
bool saving() const;
|
||||||
|
|
||||||
|
static constexpr auto kNothingFilled = 0x100;
|
||||||
|
static constexpr auto kNoTranslationFilled = 0x10;
|
||||||
|
static constexpr auto kNoSelfieFilled = 0x001;
|
||||||
|
int whatNotFilled() const;
|
||||||
|
|
||||||
std::vector<File> &files(FileType type);
|
std::vector<File> &files(FileType type);
|
||||||
const std::vector<File> &files(FileType type) const;
|
const std::vector<File> &files(FileType type) const;
|
||||||
QString &fileMissingError(FileType type);
|
QString &fileMissingError(FileType type);
|
||||||
|
|
|
@ -479,18 +479,28 @@ ScopeRow ComputeScopeRow(const Scope &scope) {
|
||||||
row.title = titleFallback;
|
row.title = titleFallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
// #TODO passport half-full value
|
if (row.error.isEmpty()
|
||||||
//if (row.error.isEmpty()
|
&& row.ready.isEmpty()
|
||||||
// && row.ready.isEmpty()
|
&& !scope.documents.empty()) {
|
||||||
// && scope.type == Scope::Type::Identity
|
if (document) {
|
||||||
// && scope.selfieRequired) {
|
row.description = (scope.type == Scope::Type::Identity)
|
||||||
// auto noSelfieScope = scope;
|
? lang(lng_passport_personal_details_enter)
|
||||||
// noSelfieScope.selfieRequired = false;
|
: lang(lng_passport_address_enter);
|
||||||
// if (!ComputeScopeRowReadyString(noSelfieScope).isEmpty()) {
|
} else {
|
||||||
// // Only selfie is missing.
|
const auto best = ranges::min(
|
||||||
// row.description = lang(lng_passport_identity_selfie);
|
scope.documents,
|
||||||
// }
|
std::less<>(),
|
||||||
//}
|
[](not_null<const Value*> document) {
|
||||||
|
return document->whatNotFilled();
|
||||||
|
});
|
||||||
|
const auto notFilled = best->whatNotFilled();
|
||||||
|
if (notFilled & Value::kNoTranslationFilled) {
|
||||||
|
row.description = lang(lng_passport_translation_needed);
|
||||||
|
} else if (notFilled & Value::kNoSelfieFilled) {
|
||||||
|
row.description = lang(lng_passport_identity_selfie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return row;
|
return row;
|
||||||
};
|
};
|
||||||
switch (scope.type) {
|
switch (scope.type) {
|
||||||
|
|
|
@ -64,11 +64,11 @@ ScanInfo CollectScanInfo(const EditFile &file) {
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
return {
|
return {
|
||||||
|
file.type,
|
||||||
FileKey{ file.fields.id, file.fields.dcId },
|
FileKey{ file.fields.id, file.fields.dcId },
|
||||||
!file.fields.error.isEmpty() ? file.fields.error : status,
|
!file.fields.error.isEmpty() ? file.fields.error : status,
|
||||||
file.fields.image,
|
file.fields.image,
|
||||||
file.deleted,
|
file.deleted,
|
||||||
file.type,
|
|
||||||
file.fields.error };
|
file.fields.error };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ std::map<FileType, ScanInfo> PrepareSpecialFiles(const Value &value) {
|
||||||
type,
|
type,
|
||||||
(i != end(value.specialScansInEdit)
|
(i != end(value.specialScansInEdit)
|
||||||
? CollectScanInfo(i->second)
|
? CollectScanInfo(i->second)
|
||||||
: ScanInfo())).first;
|
: ScanInfo(type))).first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -185,22 +185,20 @@ EditDocumentScheme GetDocumentScheme(
|
||||||
result.detailsHeader = lang(lng_passport_personal_details);
|
result.detailsHeader = lang(lng_passport_personal_details);
|
||||||
result.fieldsHeader = lang(lng_passport_document_details);
|
result.fieldsHeader = lang(lng_passport_document_details);
|
||||||
if (scansType) {
|
if (scansType) {
|
||||||
switch (*scansType) {
|
result.scansHeader = [&] {
|
||||||
case Value::Type::Passport:
|
switch (*scansType) {
|
||||||
result.scansHeader = lang(lng_passport_identity_passport);
|
case Value::Type::Passport:
|
||||||
break;
|
return lang(lng_passport_identity_passport);
|
||||||
case Value::Type::DriverLicense:
|
case Value::Type::DriverLicense:
|
||||||
result.scansHeader = lang(lng_passport_identity_license);
|
return lang(lng_passport_identity_license);
|
||||||
break;
|
case Value::Type::IdentityCard:
|
||||||
case Value::Type::IdentityCard:
|
return lang(lng_passport_identity_card);
|
||||||
result.scansHeader = lang(lng_passport_identity_card);
|
case Value::Type::InternalPassport:
|
||||||
break;
|
return lang(lng_passport_identity_internal);
|
||||||
case Value::Type::InternalPassport:
|
default:
|
||||||
result.scansHeader = lang(lng_passport_identity_internal);
|
Unexpected("scansType in GetDocumentScheme:Identity.");
|
||||||
break;
|
}
|
||||||
default:
|
}();
|
||||||
Unexpected("scansType in GetDocumentScheme:Identity.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
result.rows = {
|
result.rows = {
|
||||||
{
|
{
|
||||||
|
@ -501,6 +499,24 @@ bool SkipFieldCheck(not_null<const Value*> value, const QString &key) {
|
||||||
return dontCheckNames.find(key) != end(dontCheckNames);
|
return dontCheckNames.find(key) != end(dontCheckNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScanInfo::ScanInfo(FileType type) : type(type) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ScanInfo::ScanInfo(
|
||||||
|
FileType type,
|
||||||
|
const FileKey &key,
|
||||||
|
const QString &status,
|
||||||
|
const QImage &thumb,
|
||||||
|
bool deleted,
|
||||||
|
const QString &error)
|
||||||
|
: type(type)
|
||||||
|
, key(key)
|
||||||
|
, status(status)
|
||||||
|
, thumb(thumb)
|
||||||
|
, deleted(deleted)
|
||||||
|
, error(error) {
|
||||||
|
}
|
||||||
|
|
||||||
BoxPointer::BoxPointer(QPointer<BoxContent> value)
|
BoxPointer::BoxPointer(QPointer<BoxContent> value)
|
||||||
: _value(value) {
|
: _value(value) {
|
||||||
}
|
}
|
||||||
|
@ -912,41 +928,34 @@ void PanelController::ensurePanelCreated() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int PanelController::findNonEmptyDocumentIndex(const Scope &scope) const {
|
base::optional<int> PanelController::findBestDocumentIndex(
|
||||||
|
const Scope &scope) const {
|
||||||
|
Expects(!scope.documents.empty());
|
||||||
|
|
||||||
const auto &documents = scope.documents;
|
const auto &documents = scope.documents;
|
||||||
const auto i = ranges::find_if(
|
const auto i = ranges::min_element(
|
||||||
documents,
|
documents,
|
||||||
|
std::less<>(),
|
||||||
[](not_null<const Value*> document) {
|
[](not_null<const Value*> document) {
|
||||||
return document->scansAreFilled();
|
return document->whatNotFilled();
|
||||||
});
|
});
|
||||||
if (i != end(documents)) {
|
return ((*i)->whatNotFilled() == Value::kNothingFilled)
|
||||||
return (i - begin(documents));
|
? base::none
|
||||||
}
|
: base::make_optional(int(i - begin(documents)));
|
||||||
// If we have a document where only selfie is not filled - return it.
|
|
||||||
// #TODO passport half-full value
|
|
||||||
//const auto j = ranges::find_if(
|
|
||||||
// documents,
|
|
||||||
// [&](not_null<const Value*> document) {
|
|
||||||
// return document->scansAreFilled(false);
|
|
||||||
// });
|
|
||||||
//if (j != end(documents)) {
|
|
||||||
// return (j - begin(documents));
|
|
||||||
//}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PanelController::editScope(int index) {
|
void PanelController::editScope(int index) {
|
||||||
Expects(_panel != nullptr);
|
Expects(_panel != nullptr);
|
||||||
Expects(index >= 0 && index < _scopes.size());
|
Expects(index >= 0 && index < _scopes.size());
|
||||||
|
|
||||||
const auto &scope = _scopes[index];
|
const auto &scope = _scopes[index];
|
||||||
if (scope.documents.empty()) {
|
if (scope.documents.empty()) {
|
||||||
editScope(index, -1);
|
editScope(index, base::none);
|
||||||
} else {
|
} else {
|
||||||
const auto documentIndex = findNonEmptyDocumentIndex(scope);
|
const auto documentIndex = findBestDocumentIndex(scope);
|
||||||
if (documentIndex >= 0 || scope.documents.size() == 1) {
|
if (documentIndex || scope.documents.size() == 1) {
|
||||||
editScope(index, (documentIndex >= 0) ? documentIndex : 0);
|
editScope(index, documentIndex ? *documentIndex : 0);
|
||||||
} else {
|
} else {
|
||||||
requestScopeFilesType(index);
|
requestScopeFilesType(index);
|
||||||
}
|
}
|
||||||
|
@ -1056,16 +1065,16 @@ void PanelController::readScanError(ReadScanError error) {
|
||||||
|
|
||||||
bool PanelController::editRequiresScanUpload(
|
bool PanelController::editRequiresScanUpload(
|
||||||
int index,
|
int index,
|
||||||
int documentIndex) const {
|
base::optional<int> documentIndex) const {
|
||||||
Expects(index >= 0 && index < _scopes.size());
|
Expects(index >= 0 && index < _scopes.size());
|
||||||
Expects((documentIndex < 0)
|
Expects(!documentIndex
|
||||||
|| (documentIndex >= 0
|
|| (*documentIndex >= 0
|
||||||
&& documentIndex < _scopes[index].documents.size()));
|
&& *documentIndex < _scopes[index].documents.size()));
|
||||||
|
|
||||||
if (documentIndex < 0) {
|
if (!documentIndex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto document = _scopes[index].documents[documentIndex];
|
const auto document = _scopes[index].documents[*documentIndex];
|
||||||
if (document->requiresSpecialScan(FileType::FrontSide)) {
|
if (document->requiresSpecialScan(FileType::FrontSide)) {
|
||||||
const auto &scans = document->specialScans;
|
const auto &scans = document->specialScans;
|
||||||
return (scans.find(FileType::FrontSide) == end(scans));
|
return (scans.find(FileType::FrontSide) == end(scans));
|
||||||
|
@ -1073,26 +1082,30 @@ bool PanelController::editRequiresScanUpload(
|
||||||
return document->files(FileType::Scan).empty();
|
return document->files(FileType::Scan).empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PanelController::editScope(int index, int documentIndex) {
|
void PanelController::editScope(
|
||||||
|
int index,
|
||||||
|
base::optional<int> documentIndex) {
|
||||||
if (editRequiresScanUpload(index, documentIndex)) {
|
if (editRequiresScanUpload(index, documentIndex)) {
|
||||||
editWithUpload(index, documentIndex);
|
editWithUpload(index, *documentIndex);
|
||||||
} else {
|
} else {
|
||||||
startScopeEdit(index, documentIndex);
|
startScopeEdit(index, documentIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PanelController::startScopeEdit(int index, int documentIndex) {
|
void PanelController::startScopeEdit(
|
||||||
|
int index,
|
||||||
|
base::optional<int> documentIndex) {
|
||||||
Expects(_panel != nullptr);
|
Expects(_panel != nullptr);
|
||||||
Expects(index >= 0 && index < _scopes.size());
|
Expects(index >= 0 && index < _scopes.size());
|
||||||
Expects(_scopes[index].details != 0 || documentIndex >= 0);
|
Expects(_scopes[index].details != 0 || documentIndex.has_value());
|
||||||
Expects((documentIndex < 0)
|
Expects(!documentIndex.has_value()
|
||||||
|| (documentIndex >= 0
|
|| (*documentIndex >= 0
|
||||||
&& documentIndex < _scopes[index].documents.size()));
|
&& *documentIndex < _scopes[index].documents.size()));
|
||||||
|
|
||||||
_editScope = &_scopes[index];
|
_editScope = &_scopes[index];
|
||||||
_editValue = _editScope->details;
|
_editValue = _editScope->details;
|
||||||
_editDocument = (documentIndex >= 0)
|
_editDocument = documentIndex
|
||||||
? _scopes[index].documents[documentIndex].get()
|
? _scopes[index].documents[*documentIndex].get()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
|
||||||
if (_editValue) {
|
if (_editValue) {
|
||||||
|
|
|
@ -32,11 +32,20 @@ QString AdjustKeyName(not_null<const Value*> value, const QString &key);
|
||||||
bool SkipFieldCheck(not_null<const Value*> value, const QString &key);
|
bool SkipFieldCheck(not_null<const Value*> value, const QString &key);
|
||||||
|
|
||||||
struct ScanInfo {
|
struct ScanInfo {
|
||||||
|
explicit ScanInfo(FileType type);
|
||||||
|
ScanInfo(
|
||||||
|
FileType type,
|
||||||
|
const FileKey &key,
|
||||||
|
const QString &status,
|
||||||
|
const QImage &thumb,
|
||||||
|
bool deleted,
|
||||||
|
const QString &error);
|
||||||
|
|
||||||
|
FileType type;
|
||||||
FileKey key;
|
FileKey key;
|
||||||
QString status;
|
QString status;
|
||||||
QImage thumb;
|
QImage thumb;
|
||||||
bool deleted = false;
|
bool deleted = false;
|
||||||
FileType type = FileType();
|
|
||||||
QString error;
|
QString error;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -140,15 +149,15 @@ public:
|
||||||
private:
|
private:
|
||||||
void ensurePanelCreated();
|
void ensurePanelCreated();
|
||||||
|
|
||||||
void editScope(int index, int documentIndex);
|
void editScope(int index, base::optional<int> documentIndex);
|
||||||
void editWithUpload(int index, int documentIndex);
|
void editWithUpload(int index, int documentIndex);
|
||||||
bool editRequiresScanUpload(int index, int documentIndex) const;
|
bool editRequiresScanUpload(
|
||||||
void startScopeEdit(int index, int documentIndex);
|
int index,
|
||||||
int findNonEmptyDocumentIndex(const Scope &scope) const;
|
base::optional<int> documentIndex) const;
|
||||||
|
void startScopeEdit(int index, base::optional<int> documentIndex);
|
||||||
|
base::optional<int> findBestDocumentIndex(const Scope &scope) const;
|
||||||
void requestScopeFilesType(int index);
|
void requestScopeFilesType(int index);
|
||||||
void cancelValueEdit();
|
void cancelValueEdit();
|
||||||
std::map<FileType, ScanInfo> valueSpecialFiles(
|
|
||||||
const Value &value) const;
|
|
||||||
void processValueSaveFinished(not_null<const Value*> value);
|
void processValueSaveFinished(not_null<const Value*> value);
|
||||||
void processVerificationNeeded(not_null<const Value*> value);
|
void processVerificationNeeded(not_null<const Value*> value);
|
||||||
|
|
||||||
|
|
|
@ -330,6 +330,7 @@ not_null<Ui::RpWidget*> PanelEditDocument::setupContent(
|
||||||
object_ptr<EditScans>(
|
object_ptr<EditScans>(
|
||||||
inner,
|
inner,
|
||||||
_controller,
|
_controller,
|
||||||
|
_scheme.scansHeader,
|
||||||
*scansError,
|
*scansError,
|
||||||
std::move(specialFiles),
|
std::move(specialFiles),
|
||||||
std::move(translations)));
|
std::move(translations)));
|
||||||
|
|
|
@ -439,6 +439,7 @@ EditScans::EditScans(
|
||||||
EditScans::EditScans(
|
EditScans::EditScans(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<PanelController*> controller,
|
not_null<PanelController*> controller,
|
||||||
|
const QString &header,
|
||||||
const QString &error,
|
const QString &error,
|
||||||
std::map<FileType, ScanInfo> &&specialFiles,
|
std::map<FileType, ScanInfo> &&specialFiles,
|
||||||
base::optional<ScanListData> &&translations)
|
base::optional<ScanListData> &&translations)
|
||||||
|
@ -448,7 +449,7 @@ EditScans::EditScans(
|
||||||
, _content(this)
|
, _content(this)
|
||||||
, _scansList(_controller)
|
, _scansList(_controller)
|
||||||
, _translationsList(_controller, std::move(translations)) {
|
, _translationsList(_controller, std::move(translations)) {
|
||||||
setupSpecialScans(std::move(specialFiles));
|
setupSpecialScans(header, std::move(specialFiles));
|
||||||
}
|
}
|
||||||
|
|
||||||
base::optional<int> EditScans::validateGetErrorTop() {
|
base::optional<int> EditScans::validateGetErrorTop() {
|
||||||
|
@ -481,7 +482,7 @@ base::optional<int> EditScans::validateGetErrorTop() {
|
||||||
|| scan.file.deleted
|
|| scan.file.deleted
|
||||||
|| !scan.file.error.isEmpty()) {
|
|| !scan.file.error.isEmpty()) {
|
||||||
toggleSpecialScanError(type, true);
|
toggleSpecialScanError(type, true);
|
||||||
suggestResult(scan.header->y());
|
suggestResult(scan.header ? scan.header->y() : scan.wrap->y());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
suggestList(FileType::Translation);
|
suggestList(FileType::Translation);
|
||||||
|
@ -592,7 +593,9 @@ void EditScans::setupList(
|
||||||
st::passportFormDividerHeight));
|
st::passportFormDividerHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditScans::setupSpecialScans(std::map<FileType, ScanInfo> &&files) {
|
void EditScans::setupSpecialScans(
|
||||||
|
const QString &header,
|
||||||
|
std::map<FileType, ScanInfo> &&files) {
|
||||||
const auto requiresBothSides = files.find(FileType::ReverseSide)
|
const auto requiresBothSides = files.find(FileType::ReverseSide)
|
||||||
!= end(files);
|
!= end(files);
|
||||||
const auto title = [&](FileType type) {
|
const auto title = [&](FileType type) {
|
||||||
|
@ -665,16 +668,18 @@ void EditScans::setupSpecialScans(std::map<FileType, ScanInfo> &&files) {
|
||||||
SpecialScan(std::move(info))).first;
|
SpecialScan(std::move(info))).first;
|
||||||
auto &scan = i->second;
|
auto &scan = i->second;
|
||||||
|
|
||||||
scan.header = inner->add(
|
if (_specialScans.size() == 1) {
|
||||||
object_ptr<Ui::SlideWrap<Ui::FlatLabel>>(
|
scan.header = inner->add(
|
||||||
inner,
|
object_ptr<Ui::SlideWrap<Ui::FlatLabel>>(
|
||||||
object_ptr<Ui::FlatLabel>(
|
|
||||||
inner,
|
inner,
|
||||||
title(type),
|
object_ptr<Ui::FlatLabel>(
|
||||||
Ui::FlatLabel::InitType::Simple,
|
inner,
|
||||||
st::passportFormHeader),
|
header,
|
||||||
st::passportUploadHeaderPadding));
|
Ui::FlatLabel::InitType::Simple,
|
||||||
scan.header->toggle(scan.file.key.id != 0, anim::type::instant);
|
st::passportFormHeader),
|
||||||
|
st::passportUploadHeaderPadding));
|
||||||
|
scan.header->toggle(scan.file.key.id != 0, anim::type::instant);
|
||||||
|
}
|
||||||
scan.wrap = inner->add(object_ptr<Ui::VerticalLayout>(inner));
|
scan.wrap = inner->add(object_ptr<Ui::VerticalLayout>(inner));
|
||||||
if (scan.file.key.id) {
|
if (scan.file.key.id) {
|
||||||
createSpecialScanRow(scan, scan.file, requiresBothSides);
|
createSpecialScanRow(scan, scan.file, requiresBothSides);
|
||||||
|
@ -787,7 +792,9 @@ void EditScans::updateSpecialScan(ScanInfo &&info) {
|
||||||
createSpecialScanRow(scan, info, requiresBothSides);
|
createSpecialScanRow(scan, info, requiresBothSides);
|
||||||
scan.wrap->resizeToWidth(width());
|
scan.wrap->resizeToWidth(width());
|
||||||
scan.row->show(anim::type::normal);
|
scan.row->show(anim::type::normal);
|
||||||
scan.header->show(anim::type::normal);
|
if (scan.header) {
|
||||||
|
scan.header->show(anim::type::normal);
|
||||||
|
}
|
||||||
specialScanChanged(type, true);
|
specialScanChanged(type, true);
|
||||||
}
|
}
|
||||||
scan.file = std::move(info);
|
scan.file = std::move(info);
|
||||||
|
@ -805,12 +812,12 @@ void EditScans::createSpecialScanRow(
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case FileType::FrontSide:
|
case FileType::FrontSide:
|
||||||
return lang(requiresBothSides
|
return lang(requiresBothSides
|
||||||
? lng_passport_front_side_name
|
? lng_passport_front_side_title
|
||||||
: lng_passport_main_page_name);
|
: lng_passport_main_page_title);
|
||||||
case FileType::ReverseSide:
|
case FileType::ReverseSide:
|
||||||
return lang(lng_passport_reverse_side_name);
|
return lang(lng_passport_reverse_side_title);
|
||||||
case FileType::Selfie:
|
case FileType::Selfie:
|
||||||
return lang(lng_passport_selfie_name);
|
return lang(lng_passport_selfie_title);
|
||||||
}
|
}
|
||||||
Unexpected("Type in special file name.");
|
Unexpected("Type in special file name.");
|
||||||
}();
|
}();
|
||||||
|
|
|
@ -55,6 +55,7 @@ public:
|
||||||
EditScans(
|
EditScans(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<PanelController*> controller,
|
not_null<PanelController*> controller,
|
||||||
|
const QString &header,
|
||||||
const QString &error,
|
const QString &error,
|
||||||
std::map<FileType, ScanInfo> &&specialFiles,
|
std::map<FileType, ScanInfo> &&specialFiles,
|
||||||
base::optional<ScanListData> &&translations);
|
base::optional<ScanListData> &&translations);
|
||||||
|
@ -112,7 +113,9 @@ private:
|
||||||
not_null<Ui::VerticalLayout*> container,
|
not_null<Ui::VerticalLayout*> container,
|
||||||
FileType type,
|
FileType type,
|
||||||
const QString &header);
|
const QString &header);
|
||||||
void setupSpecialScans(std::map<FileType, ScanInfo> &&files);
|
void setupSpecialScans(
|
||||||
|
const QString &header,
|
||||||
|
std::map<FileType, ScanInfo> &&files);
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
void chooseScan(FileType type);
|
void chooseScan(FileType type);
|
||||||
|
|
Loading…
Reference in New Issue