Skip to content

Commit

Permalink
Add feature leaves apply
Browse files Browse the repository at this point in the history
But some detail not complete:
 1. submit summary
 2. image crop or resize
  • Loading branch information
abc873693 committed Sep 27, 2019
1 parent a7c994c commit ae20bbf
Show file tree
Hide file tree
Showing 12 changed files with 958 additions and 173 deletions.
1 change: 1 addition & 0 deletions assets/leaves_campus_data.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
<true/>
<key>NSCalendarsUsageDescription</key>
<string>Feature calendar would be add schedule to calendar app</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Feature leaves apply would be select photos to apply leaves</string>
<key>NSCameraUsageDescription</key>
<string>Feature leaves apply would be select photos to apply leaves</string>
<key>NSMicrophoneUsageDescription</key>
<string>Feature leaves apply would be select photos to apply leaves</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand Down
10 changes: 8 additions & 2 deletions lib/api/helper.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:dio/dio.dart';
import 'package:encrypt/encrypt.dart';
Expand Down Expand Up @@ -428,12 +429,17 @@ class Helper {
}
}

Future<Response> sendLeavesSubmit(LeavesSubmitData data) async {
Future<Response> sendLeavesSubmit(LeavesSubmitData data, File image) async {
if (isExpire()) await login(username, password);
try {
var response = await dio.post(
'/leaves/submit',
data: data.toJson(),
data: {
'leavesData': data.toJson(),
'leavesProof': image == null
? null
: UploadFileInfo(image, image.path.split('/').last),
},
cancelToken: cancelToken,
);
return response;
Expand Down
111 changes: 0 additions & 111 deletions lib/models/leave_info_data.dart

This file was deleted.

81 changes: 81 additions & 0 deletions lib/models/leave_submit_info_data.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// To parse this JSON data, do
//
// final leavesSubmitInfoData = leavesSubmitInfoDataFromJson(jsonString);

import 'dart:convert';

class LeavesSubmitInfoData {
Tutor tutor;
List<Type> type;
List<String> timeCodes;

LeavesSubmitInfoData({
this.tutor,
this.type,
this.timeCodes,
});

factory LeavesSubmitInfoData.fromRawJson(String str) => LeavesSubmitInfoData.fromJson(json.decode(str));

String toRawJson() => json.encode(toJson());

factory LeavesSubmitInfoData.fromJson(Map<String, dynamic> json) => LeavesSubmitInfoData(
tutor: json["tutor"] == null ? null : Tutor.fromJson(json["tutor"]),
type: json["type"] == null ? null : List<Type>.from(json["type"].map((x) => Type.fromJson(x))),
timeCodes: json["timeCodes"] == null ? null : List<String>.from(json["timeCodes"].map((x) => x)),
);

Map<String, dynamic> toJson() => {
"tutor": tutor == null ? null : tutor.toJson(),
"type": type == null ? null : List<dynamic>.from(type.map((x) => x.toJson())),
"timeCodes": timeCodes == null ? null : List<dynamic>.from(timeCodes.map((x) => x)),
};
}

class Tutor {
String name;
String id;

Tutor({
this.name,
this.id,
});

factory Tutor.fromRawJson(String str) => Tutor.fromJson(json.decode(str));

String toRawJson() => json.encode(toJson());

factory Tutor.fromJson(Map<String, dynamic> json) => Tutor(
name: json["name"] == null ? null : json["name"],
id: json["id"] == null ? null : json["id"],
);

Map<String, dynamic> toJson() => {
"name": name == null ? null : name,
"id": id == null ? null : id,
};
}

class Type {
String title;
String id;

Type({
this.title,
this.id,
});

factory Type.fromRawJson(String str) => Type.fromJson(json.decode(str));

String toRawJson() => json.encode(toJson());

factory Type.fromJson(Map<String, dynamic> json) => Type(
title: json["title"] == null ? null : json["title"],
id: json["id"] == null ? null : json["id"],
);

Map<String, dynamic> toJson() => {
"title": title == null ? null : title,
"id": id == null ? null : id,
};
}
97 changes: 97 additions & 0 deletions lib/models/leaves_campus_data.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// To parse this JSON data, do
//
// final campus = campusFromJson(jsonString);

import 'dart:convert';

class LeavesCampusData {
List<LeavesCampus> data;

LeavesCampusData({
this.data,
});

factory LeavesCampusData.fromRawJson(String str) => LeavesCampusData.fromJson(json.decode(str));

String toRawJson() => json.encode(toJson());

factory LeavesCampusData.fromJson(Map<String, dynamic> json) => LeavesCampusData(
data: json["data"] == null ? null : List<LeavesCampus>.from(json["data"].map((x) => LeavesCampus.fromJson(x))),
);

Map<String, dynamic> toJson() => {
"data": data == null ? null : List<dynamic>.from(data.map((x) => x.toJson())),
};
}

class LeavesCampus {
String campusName;
List<LeavesDepartment> department;

LeavesCampus({
this.campusName,
this.department,
});

factory LeavesCampus.fromRawJson(String str) => LeavesCampus.fromJson(json.decode(str));

String toRawJson() => json.encode(toJson());

factory LeavesCampus.fromJson(Map<String, dynamic> json) => LeavesCampus(
campusName: json["campusName"] == null ? null : json["campusName"],
department: json["department"] == null ? null : List<LeavesDepartment>.from(json["department"].map((x) => LeavesDepartment.fromJson(x))),
);

Map<String, dynamic> toJson() => {
"campusName": campusName == null ? null : campusName,
"department": department == null ? null : List<dynamic>.from(department.map((x) => x.toJson())),
};
}

class LeavesDepartment {
String departmentName;
List<LeavesTeacher> teacherList;

LeavesDepartment({
this.departmentName,
this.teacherList,
});

factory LeavesDepartment.fromRawJson(String str) => LeavesDepartment.fromJson(json.decode(str));

String toRawJson() => json.encode(toJson());

factory LeavesDepartment.fromJson(Map<String, dynamic> json) => LeavesDepartment(
departmentName: json["departmentName"] == null ? null : json["departmentName"],
teacherList: json["teacherList"] == null ? null : List<LeavesTeacher>.from(json["teacherList"].map((x) => LeavesTeacher.fromJson(x))),
);

Map<String, dynamic> toJson() => {
"departmentName": departmentName == null ? null : departmentName,
"teacherList": teacherList == null ? null : List<dynamic>.from(teacherList.map((x) => x.toJson())),
};
}

class LeavesTeacher {
String teacherName;
String teacherId;

LeavesTeacher({
this.teacherName,
this.teacherId,
});

factory LeavesTeacher.fromRawJson(String str) => LeavesTeacher.fromJson(json.decode(str));

String toRawJson() => json.encode(toJson());

factory LeavesTeacher.fromJson(Map<String, dynamic> json) => LeavesTeacher(
teacherName: json["teacherName"] == null ? null : json["teacherName"],
teacherId: json["teacherId"] == null ? null : json["teacherId"],
);

Map<String, dynamic> toJson() => {
"teacherName": teacherName == null ? null : teacherName,
"teacherId": teacherId == null ? null : teacherId,
};
}
4 changes: 4 additions & 0 deletions lib/models/leaves_submit_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ class LeavesSubmitData {
String leaveTypeId;
String teacherId;
String reasonText;
String delayReasonText;

LeavesSubmitData({
this.days,
this.leaveTypeId,
this.teacherId,
this.reasonText,
this.delayReasonText,
});

factory LeavesSubmitData.fromRawJson(String str) =>
Expand All @@ -28,13 +30,15 @@ class LeavesSubmitData {
leaveTypeId: json["leaveType"],
teacherId: json["teacherId"],
reasonText: json["reasonText"],
delayReasonText: json["delayReason"],
);

Map<String, dynamic> toJson() => {
"days": new List<dynamic>.from(days.map((x) => x.toJson())),
"leaveType": leaveTypeId,
"teacherId": teacherId,
"reasonText": reasonText,
"delayReason": delayReasonText,
};
}

Expand Down
Loading

0 comments on commit ae20bbf

Please sign in to comment.